mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-04-27 14:57:46 +00:00
Drop dependency on WEBrick::HTTPUtils.
This commit is contained in:
parent
6d3f4ee2dd
commit
c389a52e2c
2 changed files with 6 additions and 3 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
require 'http/cookie/version'
|
require 'http/cookie/version'
|
||||||
require 'time'
|
require 'time'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'webrick/httputils'
|
|
||||||
require 'domain_name'
|
require 'domain_name'
|
||||||
|
|
||||||
module HTTP
|
module HTTP
|
||||||
|
|
@ -203,7 +202,10 @@ class HTTP::Cookie
|
||||||
pair.strip!
|
pair.strip!
|
||||||
key, value = pair.split(/=/, 2) #/)
|
key, value = pair.split(/=/, 2) #/)
|
||||||
next unless key
|
next unless key
|
||||||
value = WEBrick::HTTPUtils.dequote(value.strip) if value
|
case value # may be nil
|
||||||
|
when /\A"(.*)"\z/
|
||||||
|
value = $1.gsub(/\\(.)/, "\\1")
|
||||||
|
end
|
||||||
|
|
||||||
case key.downcase
|
case key.downcase
|
||||||
when 'domain'
|
when 'domain'
|
||||||
|
|
|
||||||
|
|
@ -95,13 +95,14 @@ class TestHTTPCookie < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_parse_quoted
|
def test_parse_quoted
|
||||||
cookie_str =
|
cookie_str =
|
||||||
"quoted=\"value\"; Expires=Sun, 06 Nov 2011 00:11:18 GMT; Path=/"
|
"quoted=\"value\"; Expires=Sun, 06 Nov 2011 00:11:18 GMT; Path=/; comment=\"comment is \\\"comment\\\"\""
|
||||||
|
|
||||||
uri = URI.parse 'http://example'
|
uri = URI.parse 'http://example'
|
||||||
|
|
||||||
assert_equal 1, HTTP::Cookie.parse(cookie_str, :origin => uri) { |cookie|
|
assert_equal 1, HTTP::Cookie.parse(cookie_str, :origin => uri) { |cookie|
|
||||||
assert_equal 'quoted', cookie.name
|
assert_equal 'quoted', cookie.name
|
||||||
assert_equal '"value"', cookie.value
|
assert_equal '"value"', cookie.value
|
||||||
|
assert_equal 'comment is "comment"', cookie.comment
|
||||||
}.size
|
}.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue