Class: HTTPClient

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

Instance Method Summary collapse

Instance Method Details

#do_request(method, uri, query, body, header, &block) ⇒ Object



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

def do_request(method, uri, query, body, header, &block)
  start_time = Time.now.to_f
  real_response = old_do_request(method, uri, query, body, header, &block)
  duration = Time.now.to_f - start_time

  captured_request = HttpCapture::HTTPClientRequest.new(method, uri, query)
  captured_response = HttpCapture::HTTPClientResponse.new(real_response, request: captured_request, duration: duration)
  HttpCapture::RESPONSES.push(captured_response)

  real_response
end

#get_content(uri, *args, &block) ⇒ Object



19
20
21
22
# File 'lib/httpclient/capture.rb', line 19

def get_content(uri, *args, &block)
  query, header = keyword_argument(args, :query, :header)
  success_content(follow_redirect(:get, uri, query, nil, header || {}, &block))
end

#old_do_requestObject



5
# File 'lib/httpclient/capture.rb', line 5

alias :old_do_request :do_request

#old_get_contentObject



18
# File 'lib/httpclient/capture.rb', line 18

alias :old_get_content :get_content