diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-07 11:05:22 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-07 11:05:22 +0000 |
commit | 36c839f233cf77d4992bedc2a26f35b5529eb389 (patch) | |
tree | b30a56334373e885a5336b7966c6491c9b53a058 /test/webrick/test_cookie.rb | |
parent | fe1019c6659b5f628c751d289e73456e1da2313f (diff) | |
download | ruby-36c839f233cf77d4992bedc2a26f35b5529eb389.tar.gz |
* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_service):
should delete trailing LF from the result of pack("m*").
* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_connect):
- should delete trailing LF from the result of pack("m*").
- clear Request-Line not to send the sesponse by HTTPServer#run.
* lib/webrick/httputils (WEBrick::HTTPUtils.parse_qvalues):
refine regexp (and change the name of a local variable).
* lib/webrick/server.rb (WEBrick::Daemon.start): prepared stdio
don't allow changing its mode.
* test/webrick/*, sample/webrick/httpproxy.rb: add new files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick/test_cookie.rb')
-rw-r--r-- | test/webrick/test_cookie.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/webrick/test_cookie.rb b/test/webrick/test_cookie.rb new file mode 100644 index 0000000000..8826d0b81f --- /dev/null +++ b/test/webrick/test_cookie.rb @@ -0,0 +1,56 @@ +require "test/unit" +require "webrick/cookie" + +class TestWEBrickCookie < Test::Unit::TestCase + def test_new + cookie = WEBrick::Cookie.new("foo","bar") + assert_equal("foo", cookie.name) + assert_equal("bar", cookie.value) + assert_equal("foo=bar", cookie.to_s) + end + + def test_time + cookie = WEBrick::Cookie.new("foo","bar") + t = 1000000000 + cookie.max_age = t + assert_match(t.to_s, cookie.to_s) + + cookie = WEBrick::Cookie.new("foo","bar") + t = Time.at(1000000000) + cookie.expires = t + assert_equal(Time, cookie.expires.class) + assert_equal(t, cookie.expires) + ts = t.httpdate + cookie.expires = ts + assert_equal(Time, cookie.expires.class) + assert_equal(t, cookie.expires) + assert_match(ts, cookie.to_s) + end + + def test_parse + data = "" + data << '$Version="1"; ' + data << 'Customer="WILE_E_COYOTE"; $Path="/acme"; ' + data << 'Part_Number="Rocket_Launcher_0001"; $Path="/acme"; ' + data << 'Shipping="FedEx"; $Path="/acme"' + cookies = WEBrick::Cookie.parse(data) + assert_equal(1, cookies[0].version) + assert_equal("Customer", cookies[0].name) + assert_equal("WILE_E_COYOTE", cookies[0].value) + assert_equal("/acme", cookies[0].path) + assert_equal(1, cookies[1].version) + assert_equal("Part_Number", cookies[1].name) + assert_equal("Rocket_Launcher_0001", cookies[1].value) + assert_equal(1, cookies[2].version) + assert_equal("Shipping", cookies[2].name) + assert_equal("FedEx", cookies[2].value) + + data = "hoge=moge; __div__session=9865ecfd514be7f7" + cookies = WEBrick::Cookie.parse(data) + assert_equal(0, cookies[0].version) + assert_equal("hoge", cookies[0].name) + assert_equal("moge", cookies[0].value) + assert_equal("__div__session", cookies[1].name) + assert_equal("9865ecfd514be7f7", cookies[1].value) + end +end |