mirror of
https://github.com/lostisland/faraday.git
synced 2025-12-05 00:02:56 -05:00
Reuse session between requests on a single Faraday::Connection.
This commit is contained in:
parent
1d6e2ace2f
commit
b0b1e38607
@ -14,8 +14,7 @@ module Faraday
|
||||
# TODO: support streaming requests
|
||||
env[:body] = env[:body].read if env[:body].respond_to? :read
|
||||
|
||||
session = ::Patron::Session.new
|
||||
@block.call(session)
|
||||
session = @session ||= create_session
|
||||
|
||||
if req = env[:request]
|
||||
session.timeout = session.connect_timeout = req[:timeout] if req[:timeout]
|
||||
@ -44,6 +43,12 @@ module Faraday
|
||||
actions << :options unless actions.include? :options
|
||||
end
|
||||
end
|
||||
|
||||
def create_session
|
||||
session = ::Patron::Session.new
|
||||
@block.call(session)
|
||||
session
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user