Sha256: 009672260e7e8ab078e1e0c1d00f581fbc4ee92bb7670d267211d85c425a1fd3

Contents?: true

Size: 849 Bytes

Versions: 7

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

if defined?(Patron)
  module Patron
    class Session
      alias orig_request request
      def request(action_name, url, headers, options = {})
        bm = Benchmark.realtime do
          @response = orig_request(action_name, url, headers, options)
        end

        if HttpLog.url_approved?(url)
          HttpLog.call(
            method: action_name,
            url: url,
            request_body: options[:data],
            request_headers: headers,
            response_code: @response.status,
            response_body: @response.body,
            response_headers: @response.headers,
            benchmark: bm,
            encoding: @response.headers['Content-Encoding'],
            content_type: @response.headers['Content-Type']
          )
        end

        @response
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
httplog-1.3.3 lib/httplog/adapters/patron.rb
httplog-1.3.2 lib/httplog/adapters/patron.rb
httplog-1.3.1 lib/httplog/adapters/patron.rb
httplog-1.3.0 lib/httplog/adapters/patron.rb
httplog-1.2.2 lib/httplog/adapters/patron.rb
httplog-1.2.1 lib/httplog/adapters/patron.rb
httplog-1.2.0 lib/httplog/adapters/patron.rb