mirror of
https://github.com/lostisland/faraday.git
synced 2025-08-29 00:03:58 -04:00
yay, net/http can stream like nobody's business
This commit is contained in:
parent
c4fbe32533
commit
6007c76efa
@ -30,7 +30,19 @@ module Faraday
|
||||
http.open_timeout = req[:open_timeout] if req[:open_timeout]
|
||||
|
||||
full_path = full_path_for(env[:url].path, env[:url].query, env[:url].fragment)
|
||||
http_resp = http.send_request(env[:method].to_s.upcase, full_path, env[:body], env[:request_headers])
|
||||
http_req = Net::HTTPGenericRequest.new(
|
||||
env[:method].to_s.upcase, # request method
|
||||
(env[:body] ? true : false), # is there data
|
||||
true, # does net/http love you, true or false?
|
||||
full_path, # request uri path
|
||||
env[:request_headers]) # request headers
|
||||
|
||||
if env[:body].respond_to?(:read)
|
||||
http_req.body_stream = env[:body]
|
||||
env[:body] = nil
|
||||
end
|
||||
|
||||
http_resp = http.request http_req, env[:body]
|
||||
|
||||
resp_headers = {}
|
||||
http_resp.each_header do |key, value|
|
||||
@ -54,12 +66,6 @@ module Faraday
|
||||
Net::HTTP
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: build in support for multipart streaming
|
||||
def create_multipart(env, params, boundary = nil)
|
||||
stream = super
|
||||
stream.read
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,6 +7,7 @@ rescue LoadError
|
||||
raise
|
||||
end
|
||||
|
||||
# Auto-load multipart-post gem on first request.
|
||||
module Faraday
|
||||
CompositeReadIO = ::CompositeReadIO
|
||||
UploadIO = ::UploadIO
|
||||
|
Loading…
x
Reference in New Issue
Block a user