class WebAgent::CookieManager
Constants
- SPECIAL_DOMAIN
Attributes
accept_domains[RW]
format[R]
jar[R]
netscape_rule[RW]
for conformance to wp.netscape.com/newsref/std/cookie_spec.html
reject_domains[RW]
Public Class Methods
new(cookies_file = nil, format = WebAgentSaver, jar = HTTP::CookieJar.new)
click to toggle source
# File lib/httpclient/cookie.rb, line 15 def initialize(cookies_file = nil, format = WebAgentSaver, jar = HTTP::CookieJar.new) @cookies_file = cookies_file @format = format @jar = jar load_cookies if @cookies_file end
Public Instance Methods
add(cookie)
click to toggle source
# File lib/httpclient/cookie.rb, line 69 def add(cookie) @jar.add(cookie) end
find(uri)
click to toggle source
# File lib/httpclient/cookie.rb, line 73 def find(uri) warning('CookieManager#find is deprecated and will be removed in near future. Use HTTP::Cookie.cookie_value(CookieManager#cookies) instead') if cookie = cookies(uri) HTTP::Cookie.cookie_value(cookie) end end
Also aliased as: cookie_value
parse(value, uri)
click to toggle source
# File lib/httpclient/cookie.rb, line 58 def parse(value, uri) @jar.parse(value, uri) end
Private Instance Methods
check_domain(domain, hostname, override)
click to toggle source
# File lib/httpclient/webagent-cookie.rb, line 416 def check_domain(domain, hostname, override) return unless domain # [DRAFT 12] s. 4.2.2 (does not apply in the case that # host name is the same as domain attribute for version 0 # cookie) # I think that this rule has almost the same effect as the # tail match of [NETSCAPE]. if domain !~ /^\./ && hostname != domain domain = '.'+domain end # [NETSCAPE] rule if @netscape_rule n = domain.scan(/\./).length if n < 2 cookie_error(SpecialError.new, override) elsif n == 2 ## [NETSCAPE] rule ok = SPECIAL_DOMAIN.select{|sdomain| sdomain == domain[-(sdomain.length)..-1] } if ok.empty? cookie_error(SpecialError.new, override) end end end # this implementation does not check RFC2109 4.3.2 case 2; # the portion of host not in domain does not contain a dot. # according to nsCookieService.cpp in Firefox 3.0.4, Firefox 3.0.4 # and IE does not check, too. end