Drop support for obsolete attributes: version and comment.

This commit is contained in:
Akinori MUSHA 2013-04-07 23:09:30 +09:00
parent 9e46ce0d30
commit 6689b3b7aa
4 changed files with 14 additions and 21 deletions

View file

@ -77,6 +77,17 @@ equivalent using `HTTP::Cookie`:
cookies1 = HTTP::Cookie.parse(set_cookie1, uri_or_url)
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`
# before

View file

@ -158,11 +158,8 @@ class HTTP::Cookie
# new("name" => "uid", "value" => "a12345", "Domain" => 'www.example.org')
#
def initialize(*args)
@version = 0 # Netscape Cookie
@origin = @domain = @path =
@expires = @max_age =
@comment = nil
@expires = @max_age = nil
@secure = @httponly = false
@session = true
@created_at = @accessed_at = Time.now
@ -306,10 +303,6 @@ class HTTP::Cookie
cookie.expires = avalue unless cookie.max_age
when 'max-age'
cookie.max_age = avalue
when 'comment'
cookie.comment = avalue
when 'version'
cookie.version = avalue
when 'secure'
cookie.secure = avalue
when 'httponly'
@ -521,13 +514,6 @@ class HTTP::Cookie
self
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
# date for interpreting the Max-Age attribute value. See #expires.
attr_accessor :created_at
@ -610,9 +596,6 @@ class HTTP::Cookie
elsif @expires
string << "; Expires=#{@expires.httpdate}"
end
if @comment
string << "; Comment=#{Scanner.quote(@comment)}"
end
if @httponly
string << "; HttpOnly"
end

View file

@ -80,7 +80,6 @@ class HTTP::CookieJar::CookiestxtSaver < HTTP::CookieJar::AbstractSaver
:path => path,
:secure => s_secure == True,
:httponly => httponly,
:expires => expires,
:version => 0)
:expires => expires)
end
end

View file

@ -102,7 +102,6 @@ class TestHTTPCookie < Test::Unit::TestCase
assert_equal 1, HTTP::Cookie.parse(cookie_str, uri) { |cookie|
assert_equal 'quoted', cookie.name
assert_equal 'value', cookie.value
assert_equal 'comment is "comment"', cookie.comment
}.size
end
@ -127,6 +126,7 @@ class TestHTTPCookie < Test::Unit::TestCase
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;'
url = URI.parse('http://192.168.6.196/')
# The version attribute is obsolete and simply ignored
cookies = HTTP::Cookie.parse(bad_cookie, url)
assert_equal 1, cookies.size
end