Sha256: 8de810e7657ccf5c57bcca05c5a3f13be43d8bfa4fc38da6a7d998181dd516e0

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 Bytes

Contents

if defined?(Patron)
  require 'uri'

  module Patron
    class Session
      alias_method :orig_request, :request
      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
binnacle-0.5.0 lib/binnacle/http_logging/adapters/patron.rb
binnacle-0.4.9 lib/binnacle/http_logging/adapters/patron.rb
binnacle-0.4.8 lib/binnacle/http_logging/adapters/patron.rb