Class: Sumologic::Http::CookieJar
- Inherits:
-
Object
- Object
- Sumologic::Http::CookieJar
- Defined in:
- lib/sumologic/http/cookie_jar.rb
Overview
Simple cookie jar for storing and managing HTTP cookies Handles Set-Cookie response headers and Cookie request headers
Instance Method Summary collapse
-
#any? ⇒ Boolean
Check if any cookies are stored.
-
#clear ⇒ Object
Clear all stored cookies.
-
#initialize ⇒ CookieJar
constructor
A new instance of CookieJar.
-
#store_from_response(response) ⇒ Object
Store cookies from response Set-Cookie headers.
-
#to_header ⇒ Object
Format cookies for Cookie request header Returns nil if no cookies stored.
Constructor Details
#initialize ⇒ CookieJar
8 9 10 |
# File 'lib/sumologic/http/cookie_jar.rb', line 8 def initialize = {} end |
Instance Method Details
#any? ⇒ Boolean
Check if any cookies are stored
30 31 32 |
# File 'lib/sumologic/http/cookie_jar.rb', line 30 def any? .any? end |
#clear ⇒ Object
Clear all stored cookies
35 36 37 |
# File 'lib/sumologic/http/cookie_jar.rb', line 35 def clear .clear end |
#store_from_response(response) ⇒ Object
Store cookies from response Set-Cookie headers
13 14 15 16 17 18 19 |
# File 'lib/sumologic/http/cookie_jar.rb', line 13 def store_from_response(response) return unless response['Set-Cookie'] Array(response['Set-Cookie']).each do || parse_and_store() end end |
#to_header ⇒ Object
Format cookies for Cookie request header Returns nil if no cookies stored
23 24 25 26 27 |
# File 'lib/sumologic/http/cookie_jar.rb', line 23 def to_header return nil if .empty? .map { |name, value| "#{name}=#{value}" }.join('; ') end |