module Netrecording::NetHTTP

Public Instance Methods

request(req, body = nil) { |response and return| ... } click to toggle source

request is overridden and the request and response are stored as a hash that can be written to a cache file

# File lib/netrecording/http.rb, line 8
def request(req, body = nil, &block)
  response = alias_for_request(req, body)

  unless Netrecording.recording?
    yield response and return if block
    return response
  end

  path = "http://#{req.bauth if req.bauth}#{req['host']}#{req.path}"
  Netrecording.records << { method: req.method, path: path, request: req, response: response }

  yield response if block
  response
end