Class: Protocol::HTTP::Header::SetCookie

Inherits:
Multiple
  • Object
show all
Defined in:
lib/protocol/http/header/set_cookie.rb

Overview

The set-cookie header sends cookies from the server to the user agent.

Each Set-Cookie header must be a separate header field — they cannot be combined. It is used to store cookies on the client side, which are then sent back to the server in subsequent requests using the cookie header.

Class Method Summary collapse

Instance Method Summary collapse

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.

Returns:

  • (Boolean)


31
32
33
# File 'lib/protocol/http/header/set_cookie.rb', line 31

def self.trailer?
	false
end

Instance Method Details

#to_hObject

Parses the set-cookie headers into a hash of cookie names and their corresponding cookie objects.



21
22
23
24
25
26
27
# File 'lib/protocol/http/header/set_cookie.rb', line 21

def to_h
	cookies = self.collect do |string|
		HTTP::Cookie.parse(string)
	end
	
	cookies.map{|cookie| [cookie.name, cookie]}.to_h
end