Class: CookieStore
- Inherits:
-
Object
- Object
- CookieStore
- Defined in:
- lib/cookie_store.rb,
lib/cookie_store/version.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Cookie, CookieParser, HashStore
Constant Summary collapse
- MAX_COOKIE_LENGTH =
Maximum number of bytes per cookie (RFC 6265 6.1 requires at least 4096)
4096
- MAX_COOKIES_PER_DOMAIN =
Maximum number of cookies per domain (RFC 6265 6.1 requires 50 at least)
50
- MAX_COOKIES_TOTAL =
Maximum number of cookies total (RFC 6265 6.1 requires 3000 at least)
3000
- VERSION =
'0.2'
Instance Method Summary collapse
- #close_session ⇒ Object
- #cookie_header_for(request_uri) ⇒ Object
-
#search_domains_for(domain) ⇒ Object
(RFC 2965, section 1).
-
#set_cookie(request_uri, set_cookie_value) ⇒ Object
Read and set the cookie from the Set-Cookie header.
Instance Method Details
#close_session ⇒ Object
63 64 65 |
# File 'lib/cookie_store.rb', line 63 def close_session gc(true) end |
#cookie_header_for(request_uri) ⇒ Object
31 32 33 |
# File 'lib/cookie_store.rb', line 31 def (request_uri) (request_uri).map(&:to_s).join('; ') end |
#search_domains_for(domain) ⇒ Object
(RFC 2965, section 1)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cookie_store.rb', line 36 def search_domains_for(domain) domain.downcase! serach_domains = [] if domain =~ CookieStore::Cookie::IPADDR serach_domains << domain else domain = domain + '.local' if !(domain =~ /.\../) serach_domains << domain serach_domains << ".#{domain}" # H is the host domain name of a host; and, # H has the form A.B; and if domain =~ /[^\.]+(\..+)/ reach = $1 # B has at least one embedded dot if reach =~ /.[\.:]./ # B has at least one embedded dot, or B is the string "local". # then the reach of H is .B. serach_domains << reach end end end serach_domains end |
#set_cookie(request_uri, set_cookie_value) ⇒ Object
Read and set the cookie from the Set-Cookie header
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cookie_store.rb', line 17 def (request_uri, ) request_uri = URI.parse(request_uri) CookieStore::Cookie.(request_uri, ) do || # reject as per RFC2965 Section 3.3.2 return if !.request_match?(request_uri) || !(.domain =~ /.+\..+/ || .domain == 'localhost') # reject cookies over the max-bytes return if .to_s.size > MAX_COOKIE_LENGTH add() end end |