Class: Faraday::CookieJar
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::CookieJar
- Defined in:
- lib/faraday/cookie_jar.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ CookieJar
constructor
A new instance of CookieJar.
Constructor Details
#initialize(app, options = {}) ⇒ CookieJar
Returns a new instance of CookieJar.
6 7 8 9 |
# File 'lib/faraday/cookie_jar.rb', line 6 def initialize(app, = {}) super(app) @jar = [:jar] || HTTP::CookieJar.new end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/faraday/cookie_jar.rb', line 11 def call(env) = @jar.(env[:url]) unless .empty? = HTTP::Cookie.() if env[:request_headers]["Cookie"] unless env[:request_headers]["Cookie"] == env[:request_headers]["Cookie"] = + ';' + env[:request_headers]["Cookie"] end else env[:request_headers]["Cookie"] = end end @app.call(env).on_complete do |res| if res[:response_headers] if = res[:response_headers]["Set-Cookie"] @jar.parse(, env[:url]) end end end end |