Sha256: 485c734a903e05c42a4ddefdbf9440e529172e17d790311ceb022e25a50d84ac
Contents?: true
Size: 801 Bytes
Versions: 30
Compression:
Stored size: 801 Bytes
Contents
module HTTPI # = HTTPI::CookieStore # # Stores a unique list of cookies for future requests. # # == Examples # # # Add one or more cookies to the store # cookie_store = HTTPI::CookieStore.new # cookie_store.add HTTPI::Cookie.new("token=choc-choc-chip; Path=/; HttpOnly") # # # Fetch the names and values for the "Cookie" header # cookie_store.fetch # => "token=choc-choc-chip" class CookieStore def initialize @cookies = {} end # Adds one or more cookies to the store. def add(*cookies) cookies.each do |cookie| @cookies[cookie.name] = cookie.name_and_value end end # Returns the names and values for the "Cookie" header. def fetch @cookies.values.join(";") unless @cookies.empty? end end end
Version data entries
30 entries across 30 versions & 1 rubygems