Class: Patron::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/binnacle/http_logging/adapters/patron.rb

Instance Method Summary collapse

Instance Method Details

#orig_requestObject



6
# File 'lib/binnacle/http_logging/adapters/patron.rb', line 6

alias_method :orig_request, :request

#request(action_name, url, headers, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/binnacle/http_logging/adapters/patron.rb', line 7

def request(action_name, url, headers, options = {})
  log_enabled = Binnacle::HttpLogger.allow?(url)

  bm = Benchmark.realtime do
    @response = orig_request(action_name, url, headers, options)
  end

  if log_enabled
    headers = @response.headers
    uri = URI(url)
    url_without_query = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}"

    Binnacle::HttpLogger.signal(url_without_query, action_name, uri.host, uri.port, uri.path, uri.query, @response.status, bm, headers, @response.body, headers['Content-Encoding'], headers['Content-Type'], options[:data])
  end
end