diff --git a/lib/faraday/adapter/excon.rb b/lib/faraday/adapter/excon.rb index b0ea0d7d7..7610b53f9 100644 --- a/lib/faraday/adapter/excon.rb +++ b/lib/faraday/adapter/excon.rb @@ -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)