Sha256: b163ff22f1a87bc9d5017a32ff7dd420d07e4ee05eabea9ec9fcfc395d50458a

Contents?: true

Size: 886 Bytes

Versions: 3

Compression:

Stored size: 886 Bytes

Contents

if defined?(Patron)
  module Patron
    class Session
      alias_method :orig_request, :request
      def request(action_name, url, headers, options = {})
        log_enabled = HttpLog.url_approved?(url)

        if log_enabled
          HttpLog.log_request(action_name, url)
          HttpLog.log_headers(headers)
          HttpLog.log_data(options[:data])# if action_name == :post
        end

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

        if log_enabled
          headers = @response.headers
          HttpLog.log_compact(action_name, url, @response.status, bm)
          HttpLog.log_status(@response.status)
          HttpLog.log_benchmark(bm)
          HttpLog.log_body(@response.body, headers['Content-Encoding'], headers['Content-Type'])
        end

        @response
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
httplog-0.99.7 lib/httplog/adapters/patron.rb
httplog-0.99.6 lib/httplog/adapters/patron.rb
httplog-0.99.5 lib/httplog/adapters/patron.rb