Module: VCR::LibraryHooks::Typhoeus

Defined in:
lib/vcr/library_hooks/typhoeus_0.4.rb,
lib/vcr/library_hooks/typhoeus.rb

Defined Under Namespace

Classes: RequestHandler

Class Method Summary collapse

Class Method Details

.collect_chunks(request) ⇒ Object


94
95
96
97
98
99
100
101
102
# File 'lib/vcr/library_hooks/typhoeus.rb', line 94

def collect_chunks(request)
  chunks = ''
  request.on_body.unshift(
    Proc.new do |body, response|
      chunks += body
      request.instance_variable_set(:@chunked_body, chunks)
    end
  )
end

.restore_body_from_chunks(response, request) ⇒ Object


104
105
106
# File 'lib/vcr/library_hooks/typhoeus.rb', line 104

def restore_body_from_chunks(response, request)
  response.options[:response_body] = request.instance_variable_get(:@chunked_body)
end

.vcr_response_from(response) ⇒ Object


57
58
59
60
61
62
63
64
# File 'lib/vcr/library_hooks/typhoeus_0.4.rb', line 57

def vcr_response_from(response)
  VCR::Response.new \
    VCR::ResponseStatus.new(response.code, response.status_message),
    response.headers,
    response.body,
    response.http_version,
    { "effective_url" => response.effective_url }
end