Module: HttpUtilities::Http::Cookies
- Included in:
- Client
- Defined in:
- lib/http_utilities/http/cookies.rb
Instance Method Summary collapse
- #format_cookies(cookies) ⇒ Object
- #handle_cookies(response) ⇒ Object
- #set_cookies(headers, cookies) ⇒ Object
Instance Method Details
#format_cookies(cookies) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/http_utilities/http/cookies.rb', line 26 def () = "" .each {|| += "#{cookie}; "} return end |
#handle_cookies(response) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/http_utilities/http/cookies.rb', line 5 def (response) = nil if (response && response.is_a?(Net::HTTPResponse)) = response.get_fields('Set-Cookie') if ( && .any?) = [] .each do || = .split('; ').first << end end elsif (response && response.is_a?(HttpUtilities::Http::Response)) = (response.request && response.request.) ? response.request. : nil end return end |
#set_cookies(headers, cookies) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/http_utilities/http/cookies.rb', line 33 def (headers, ) if ( && .any?) = ( && .is_a?(Array)) ? () : nil if () = {'cookie' => } headers = (headers && !headers.empty?) ? headers.merge() : end end return headers end |