Sha256: f9191458d7ca938e0f1944ca18d2bc50a7b5c2052f886dd4cdeff3b9db9e7930

Contents?: true

Size: 774 Bytes

Versions: 4

Compression:

Stored size: 774 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
          HttpLog.log_compact(action_name, url, @response.status, bm)
          HttpLog.log_status(@response.status)
          HttpLog.log_benchmark(bm)
          HttpLog.log_body(@response.body)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
httplog-0.2.8 lib/httplog/adapters/patron.rb
httplog-0.2.7 lib/httplog/adapters/patron.rb
httplog-0.2.6 lib/httplog/adapters/patron.rb
httplog-0.2.5 lib/httplog/adapters/patron.rb