Module: VCR::LibraryHooks::Typhoeus

Defined in:
lib/vcr/library_hooks/typhoeus.rb

Defined Under Namespace

Classes: RequestHandler

Class Method Summary collapse

Class Method Details

.collect_chunks(request) ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'lib/vcr/library_hooks/typhoeus.rb', line 79

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



89
90
91
# File 'lib/vcr/library_hooks/typhoeus.rb', line 89

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

.vcr_response_from(response) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/vcr/library_hooks/typhoeus.rb', line 70

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