Class: Protocol::HTTP::Header::Cookie
- Defined in:
- lib/protocol/http/header/cookie.rb
Overview
The ‘cookie` header contains stored HTTP cookies previously sent by the server with the `set-cookie` header.
It is used by clients to send key-value pairs representing stored cookies back to the server.
Direct Known Subclasses
Class Method Summary collapse
-
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers.
Instance Method Summary collapse
-
#to_h ⇒ Object
Parses the ‘cookie` header into a hash of cookie names and their corresponding cookie objects.
Methods inherited from Multiple
coerce, #initialize, parse, #to_s
Constructor Details
This class inherits a constructor from Protocol::HTTP::Header::Multiple
Class Method Details
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers. Cookie headers should not appear in trailers as they contain state information needed early in processing.
30 31 32 |
# File 'lib/protocol/http/header/cookie.rb', line 30 def self.trailer? false end |
Instance Method Details
#to_h ⇒ Object
Parses the ‘cookie` header into a hash of cookie names and their corresponding cookie objects.
19 20 21 22 23 24 25 |
# File 'lib/protocol/http/header/cookie.rb', line 19 def to_h = self.collect do |string| HTTP::Cookie.parse(string) end .map{|| [.name, ]}.to_h end |