Object
# File lib/httpclient/cookie.rb, line 328 def add(cookie) url = cookie.url name, value = cookie.name, cookie.value expires, domain, path = cookie.expires, cookie.domain, cookie.path secure, domain_orig, path_orig = cookie.secure?, cookie.domain_orig?, cookie.path_orig? discard, override = cookie.discard?, cookie.override? domainname = url.host domain_orig, path_orig = domain, path use_security = override if 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 !~ /^\./ && domainname != domain domain = '.'+domain end # [NETSCAPE] rule if @netscape_rule n = total_dot_num(domain) 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 path ||= url.path.sub(%/[^/]*|, '') domain ||= domainname @cookies.synchronize do cookie = find_cookie_info(domain, path, name) if !cookie cookie = WebAgent::Cookie.new() cookie.use = true @cookies << cookie end check_expired_cookies() end cookie.url = url cookie.name = name cookie.value = value cookie.expires = expires cookie.domain = domain cookie.path = path ## for flag cookie.secure = secure cookie.domain_orig = domain_orig cookie.path_orig = path_orig if discard || cookie.expires == nil cookie.discard = true else cookie.discard = false @is_saved = false end end
# File lib/httpclient/cookie.rb, line 298 def find(url) return nil if @cookies.empty? cookie_list = Array.new() @cookies.each{|cookie| is_expired = (cookie.expires && (cookie.expires < Time.now.gmtime)) if cookie.use? && !is_expired && cookie.match?(url) if cookie_list.select{|c1| c1.name == cookie.name}.empty? cookie_list << cookie end end } return make_cookie_str(cookie_list) end
Generated with the Darkfish Rdoc Generator 2.