diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-10-30 20:40:05 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-10-30 20:40:05 +0000 |
commit | d61b409d777dd7e0c10243098d0eb6d6ee29a8ea (patch) | |
tree | 862ede7646ebbd0c876cfd294df72ba6c2b5e7fa /lib/webrick/cookie.rb | |
parent | 2daff50a5727e02145b5ed9db23eb1fb80e8f590 (diff) | |
download | ruby-d61b409d777dd7e0c10243098d0eb6d6ee29a8ea.tar.gz ruby-d61b409d777dd7e0c10243098d0eb6d6ee29a8ea.tar.xz ruby-d61b409d777dd7e0c10243098d0eb6d6ee29a8ea.zip |
* lib/webrick/httpservlet/cgihandler.rb
(WEBrick::HTTPServlet::CGIHandler#do_GET): the value of Set-Cookie:
header field should be splited into each cookie. [ruby-Bugs:2199]
* lib/webrick/cookie.rb (WEBrick::Cookie.parse_set_cookie): new method
to parse the value of Set-Cookie: header field.
* test/webrick/test_cookie.rb, test/webrick/test_cgi.rb,
test/webrick/webrick.cgi: add some test for cookie.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/cookie.rb')
-rw-r--r-- | lib/webrick/cookie.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/webrick/cookie.rb b/lib/webrick/cookie.rb index 4785b2bb3..b9663dc79 100644 --- a/lib/webrick/cookie.rb +++ b/lib/webrick/cookie.rb @@ -76,5 +76,29 @@ module WEBrick end end + def self.parse_set_cookie(str) + cookie_elem = str.split(/;/) + first_elem = cookie_elem.shift + first_elem.strip! + key, value = first_elem.split(/=/, 2) + cookie = new(key, HTTPUtils.dequote(value)) + cookie_elem.each{|pair| + pair.strip! + key, value = pair.split(/=/, 2) + if value + value = HTTPUtils.dequote(value.strip) + end + case key.downcase + when "domain" then cookie.domain = value + when "path" then cookie.path = value + when "expires" then cookie.expires = value + when "max-age" then cookie.max_age = Integer(value) + when "comment" then cookie.comment = value + when "version" then cookie.version = Integer(value) + when "secure" then cookie.secure = true + end + } + return cookie + end end end |