Class: Net::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/net/http/capture.rb

Instance Method Summary collapse

Instance Method Details

#old_requestObject



6
# File 'lib/net/http/capture.rb', line 6

alias :old_request :request

#request(req, body = nil, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/net/http/capture.rb', line 7

def request(req, body = nil, &block)
  start_time = Time.now.to_f
  real_response = old_request(req, body, &block)
  duration = Time.now.to_f - start_time

  captured_request = HttpCapture::Request.new(req)
  captured_response = HttpCapture::NetHTTPResponse.new(real_response, request: captured_request, duration: duration)
  HttpCapture::RESPONSES.push(captured_response)

  real_response
end