class VCR::Middleware::Excon::StreamingResponseBodyReader
Wraps an Excon
streaming `:response_block`, so that we can accumulate the response as it streams back from the real HTTP server in order to record it.
@private
Public Class Methods
new(response_block)
click to toggle source
# File lib/vcr/middleware/excon.rb, line 177 def initialize(response_block) @response_block = response_block @chunks = [] end
Public Instance Methods
call(chunk, remaining_bytes, total_bytes)
click to toggle source
@private
# File lib/vcr/middleware/excon.rb, line 183 def call(chunk, remaining_bytes, total_bytes) @chunks << chunk @response_block.call(chunk, remaining_bytes, total_bytes) end
read_body_from(response_params)
click to toggle source
Provides a duck-typed interface that matches that of `NonStreamingResponseBodyReader`. The request handler will use this to get the response body.
@private
# File lib/vcr/middleware/excon.rb, line 193 def read_body_from(response_params) if @chunks.none? # Not sure why, but sometimes the body comes through the params # instead of via the streaming block even when the block was # configured. response_params[:body] else @chunks.join('') end end