Sha256: a47b5c3a010c094d55fe03cf7da23b4c4ee21ba58a8e1afcb0bd70b593202bfa
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
module Net class HTTP alias_method(:orig_request, :request) unless method_defined?(:orig_request) alias_method(:orig_connect, :connect) unless method_defined?(:orig_connect) def request(req, body = nil, &block) url = "http://#{@address}:#{@port}#{req.path}" log_enabled = HttpLog.url_approved?(url) if log_enabled && started? HttpLog.log_request(req.method, url) HttpLog.log_headers(req.each_header.collect) # A bit convoluted becase post_form uses form_data= to assign the data, so # in that case req.body will be empty. HttpLog::log_data(req.body.nil? || req.body.size == 0 ? body : req.body) #if req.method == 'POST' end bm = Benchmark.realtime do @response = orig_request(req, body, &block) end if log_enabled && started? HttpLog.log_compact(req.method, url, @response.code, bm) HttpLog.log_status(@response.code) HttpLog.log_benchmark(bm) HttpLog.log_headers(@response.each_header.collect) HttpLog.log_body(@response.body, @response.header["Content-Encoding"]) end @response end def connect HttpLog.log_connection(@address, @port) if !started? && HttpLog.url_approved?("#{@address}:#{@port}") orig_connect end end end
Version data entries
6 entries across 6 versions & 1 rubygems