Sha256: a8b2521cb537156de522034b8b373b04a15d48a98c0ae96f26e7c6bf7ec6b55a

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 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)
          normalized_headers = @response.headers.transform_keys(&:downcase)

          HttpLog.call(
            method: action_name,
            url: url,
            request_body: options[:data],
            request_headers: headers,
            response_code: @response.status,
            response_body: @response.body,
            response_headers: normalized_headers,
            benchmark: bm,
            encoding: normalized_headers['content-encoding'],
            content_type: normalized_headers['content-type'],
            mask_body: HttpLog.masked_body_url?(url)
          )
        end

        @response
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
httplog-1.7.0 lib/httplog/adapters/patron.rb
httplog-1.6.3 lib/httplog/adapters/patron.rb