Sha256: 0d0d83fe7d90f488674c89530620769c3f1a24c3d9727c3fb4153af20597efa8
Contents?: true
Size: 1.92 KB
Versions: 3
Compression:
Stored size: 1.92 KB
Contents
if defined?(Excon) module Excon class Socket alias_method :orig_connect, :connect def connect host = @data[:proxy] ? @data[:proxy][:host] : @data[:host] port = @data[:proxy] ? @data[:proxy][:port] : @data[:port] HttpLog.log_connection(host, port) orig_connect end end class Connection def _httplog_url(datum) "#{datum[:scheme]}://#{datum[:host]}:#{datum[:port]}#{datum[:path]}#{datum[:query]}" end alias_method :orig_request, :request def request(params, &block) result = nil bm = Benchmark.realtime do result = orig_request(params, &block) end datum = @data.merge(params) datum[:headers] = @data[:headers].merge(datum[:headers] || {}) url = _httplog_url(datum) if HttpLog.url_approved?(url) HttpLog.log_compact(datum[:method], url, datum[:status] || result.status, bm) HttpLog.log_benchmark(bm) end result end alias_method :orig_request_call, :request_call def request_call(datum) url = _httplog_url(datum) if HttpLog.url_approved?(url) HttpLog.log_request(datum[:method], _httplog_url(datum)) HttpLog.log_headers(datum[:headers]) HttpLog.log_data(datum[:body])# if datum[:method] == :post end orig_request_call(datum) end alias_method :orig_response, :response def response(datum={}) return orig_response(datum) unless HttpLog.url_approved?(_httplog_url(datum)) bm = Benchmark.realtime do datum = orig_response(datum) end response = datum[:response] headers = response[:headers] || {} HttpLog.log_status(response[:status]) HttpLog.log_headers(headers) HttpLog.log_body(response[:body], headers['Content-Encoding'], headers['Content-Type']) datum end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
httplog-1.0.2 | lib/httplog/adapters/excon.rb |
httplog-1.0.1 | lib/httplog/adapters/excon.rb |
httplog-1.0.0 | lib/httplog/adapters/excon.rb |