mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-04-27 14:57:46 +00:00
Drop support for obsolete attributes: version and comment.
This commit is contained in:
parent
9e46ce0d30
commit
6689b3b7aa
4 changed files with 14 additions and 21 deletions
11
README.md
11
README.md
|
|
@ -77,6 +77,17 @@ equivalent using `HTTP::Cookie`:
|
||||||
cookies1 = HTTP::Cookie.parse(set_cookie1, uri_or_url)
|
cookies1 = HTTP::Cookie.parse(set_cookie1, uri_or_url)
|
||||||
cookies2 = HTTP::Cookie.parse(set_cookie2, uri_or_url, :logger => log)
|
cookies2 = HTTP::Cookie.parse(set_cookie2, uri_or_url, :logger => log)
|
||||||
|
|
||||||
|
- `Mechanize::Cookie#version`, `#version=`
|
||||||
|
|
||||||
|
There is no longer a sense of version in HTTP cookie. The only
|
||||||
|
version number that has ever been defined was zero, and there will
|
||||||
|
be no other version since the version attribute has been removed
|
||||||
|
in RFC 6265.
|
||||||
|
|
||||||
|
- `Mechanize::Cookie#comment`, `#comment=`
|
||||||
|
|
||||||
|
Ditto. The comment attribute has been removed in RFC 6265.
|
||||||
|
|
||||||
- `Mechanize::Cookie#set_domain`
|
- `Mechanize::Cookie#set_domain`
|
||||||
|
|
||||||
# before
|
# before
|
||||||
|
|
|
||||||
|
|
@ -158,11 +158,8 @@ class HTTP::Cookie
|
||||||
# new("name" => "uid", "value" => "a12345", "Domain" => 'www.example.org')
|
# new("name" => "uid", "value" => "a12345", "Domain" => 'www.example.org')
|
||||||
#
|
#
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@version = 0 # Netscape Cookie
|
|
||||||
|
|
||||||
@origin = @domain = @path =
|
@origin = @domain = @path =
|
||||||
@expires = @max_age =
|
@expires = @max_age = nil
|
||||||
@comment = nil
|
|
||||||
@secure = @httponly = false
|
@secure = @httponly = false
|
||||||
@session = true
|
@session = true
|
||||||
@created_at = @accessed_at = Time.now
|
@created_at = @accessed_at = Time.now
|
||||||
|
|
@ -306,10 +303,6 @@ class HTTP::Cookie
|
||||||
cookie.expires = avalue unless cookie.max_age
|
cookie.expires = avalue unless cookie.max_age
|
||||||
when 'max-age'
|
when 'max-age'
|
||||||
cookie.max_age = avalue
|
cookie.max_age = avalue
|
||||||
when 'comment'
|
|
||||||
cookie.comment = avalue
|
|
||||||
when 'version'
|
|
||||||
cookie.version = avalue
|
|
||||||
when 'secure'
|
when 'secure'
|
||||||
cookie.secure = avalue
|
cookie.secure = avalue
|
||||||
when 'httponly'
|
when 'httponly'
|
||||||
|
|
@ -521,13 +514,6 @@ class HTTP::Cookie
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# The version attribute. The only known version of the cookie
|
|
||||||
# format is 0.
|
|
||||||
attr_accessor :version
|
|
||||||
|
|
||||||
# The comment attribute.
|
|
||||||
attr_accessor :comment
|
|
||||||
|
|
||||||
# The time this cookie was created at. This value is used as a base
|
# The time this cookie was created at. This value is used as a base
|
||||||
# date for interpreting the Max-Age attribute value. See #expires.
|
# date for interpreting the Max-Age attribute value. See #expires.
|
||||||
attr_accessor :created_at
|
attr_accessor :created_at
|
||||||
|
|
@ -610,9 +596,6 @@ class HTTP::Cookie
|
||||||
elsif @expires
|
elsif @expires
|
||||||
string << "; Expires=#{@expires.httpdate}"
|
string << "; Expires=#{@expires.httpdate}"
|
||||||
end
|
end
|
||||||
if @comment
|
|
||||||
string << "; Comment=#{Scanner.quote(@comment)}"
|
|
||||||
end
|
|
||||||
if @httponly
|
if @httponly
|
||||||
string << "; HttpOnly"
|
string << "; HttpOnly"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ class HTTP::CookieJar::CookiestxtSaver < HTTP::CookieJar::AbstractSaver
|
||||||
:path => path,
|
:path => path,
|
||||||
:secure => s_secure == True,
|
:secure => s_secure == True,
|
||||||
:httponly => httponly,
|
:httponly => httponly,
|
||||||
:expires => expires,
|
:expires => expires)
|
||||||
:version => 0)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,6 @@ class TestHTTPCookie < Test::Unit::TestCase
|
||||||
assert_equal 1, HTTP::Cookie.parse(cookie_str, uri) { |cookie|
|
assert_equal 1, HTTP::Cookie.parse(cookie_str, 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
|
||||||
|
|
||||||
|
|
@ -127,6 +126,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
||||||
def test_parse_bad_version
|
def test_parse_bad_version
|
||||||
bad_cookie = 'PRETANET=TGIAqbFXtt; Name=/PRETANET; Path=/; Version=1.2; Content-type=text/html; Domain=192.168.6.196; expires=Friday, 13-November-2026 23:01:46 GMT;'
|
bad_cookie = 'PRETANET=TGIAqbFXtt; Name=/PRETANET; Path=/; Version=1.2; Content-type=text/html; Domain=192.168.6.196; expires=Friday, 13-November-2026 23:01:46 GMT;'
|
||||||
url = URI.parse('http://192.168.6.196/')
|
url = URI.parse('http://192.168.6.196/')
|
||||||
|
# The version attribute is obsolete and simply ignored
|
||||||
cookies = HTTP::Cookie.parse(bad_cookie, url)
|
cookies = HTTP::Cookie.parse(bad_cookie, url)
|
||||||
assert_equal 1, cookies.size
|
assert_equal 1, cookies.size
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue