Sha256: d3aa650f1a3584ecbf787f4b3a909ba163df221544d34c6dd2efbf3be2dd1c11

Contents?: true

Size: 867 Bytes

Versions: 8

Compression:

Stored size: 867 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
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
httplog-0.99.4 lib/httplog/adapters/patron.rb
httplog-0.99.3 lib/httplog/adapters/patron.rb
httplog-0.99.2 lib/httplog/adapters/patron.rb
httplog-0.99.1 lib/httplog/adapters/patron.rb
httplog-0.3.3 lib/httplog/adapters/patron.rb
httplog-0.3.2 lib/httplog/adapters/patron.rb
httplog-0.3.1 lib/httplog/adapters/patron.rb
httplog-0.3.0 lib/httplog/adapters/patron.rb