Class: Faraday::Adapter::NetHttpStream
- Inherits:
-
Adapter::NetHttp
- Object
- Adapter::NetHttp
- Faraday::Adapter::NetHttpStream
- Defined in:
- lib/tent-client/faraday/chunked_adapter.rb
Defined Under Namespace
Classes: BodyStream
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tent-client/faraday/chunked_adapter.rb', line 30 def call(env) env[:request_body] = env[:body] request = new_request(env) stream_body = proc do |callback| @read_proc = callback request.resume end response = request.resume body = BodyStream.new(env, &stream_body) save_response(env, response.code.to_i, body) do |response_headers| response.each_header do |key, value| response_headers[key] = value end end @app.call(env) rescue *Adapter::NetHttp::NET_HTTP_EXCEPTIONS raise Error::ConnectionFailed, $! rescue Timeout::Error => err raise Faraday::Error::TimeoutError, err end |