Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excon streaming #1026

Merged
merged 4 commits into from Sep 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/faraday/adapter/excon.rb
Expand Up @@ -12,16 +12,21 @@ def call(env)
opts = opts_from_env(env)
conn = create_connection(env, opts)

resp = conn.request(method: env[:method].to_s.upcase,
headers: env[:request_headers],
body: read_body(env))
req_opts = {
method: env[:method].to_s.upcase,
headers: env[:request_headers],
body: read_body(env)
}

req = env[:request]
if req&.stream_response?
warn "Streaming downloads for #{self.class.name} are not yet " \
' implemented.'
req.on_data.call(resp.body, resp.body.bytesize)
total = 0
req_opts[:response_block] = lambda do |chunk, _remain, _total|
req.on_data.call(chunk, total += chunk.size)
end
end

resp = conn.request(req_opts)
save_response(env, resp.status.to_i, resp.body, resp.headers,
resp.reason_phrase)

Expand Down