Skip to content

Commit

Permalink
fix request header cookie set error
Browse files Browse the repository at this point in the history
  • Loading branch information
nanjingboy committed Jan 21, 2014
1 parent 0b57360 commit 1e555e8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/faraday/cookie_jar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ def initialize(app, options = {})
def call(env)
cookies = @jar.cookies(env[:url])
unless cookies.empty?
env[:request_headers]["Cookie"] += ';' + HTTP::Cookie.cookie_value(cookies)
cookie_value = HTTP::Cookie.cookie_value(cookies)
if env[:request_headers]["Cookie"]
env[:request_headers]["Cookie"] = cookie_value + ';' + env[:request_headers]["Cookie"]
else
env[:request_headers]["Cookie"] = cookie_value
end
end

@app.call(env).on_complete do |res|
Expand All @@ -27,4 +32,4 @@ def call(env)

if Faraday.respond_to? :register_middleware
Faraday.register_middleware :cookie_jar => lambda { Faraday::CookieJar }
end
end

0 comments on commit 1e555e8

Please sign in to comment.