Sha256: 1430966a17b75a2b615ec4c5aa1a4ce2dca0f9ce4cda5061b5fcea17b0cfe14e

Contents?: true

Size: 903 Bytes

Versions: 6

Compression:

Stored size: 903 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'],
            mask_body: HttpLog.masked_body_url?(url)
          )
        end

        @response
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
httplog-1.6.2 lib/httplog/adapters/patron.rb
httplog-1.6.1 lib/httplog/adapters/patron.rb
httplog-1.6.0 lib/httplog/adapters/patron.rb
httplog-1.5.0 lib/httplog/adapters/patron.rb
httplog-1.4.3 lib/httplog/adapters/patron.rb
httplog-1.4.2 lib/httplog/adapters/patron.rb