Class: Excon::Connection

Inherits:
Object
  • Object
show all
Includes:
HttpLogHelper
Defined in:
lib/httplog/adapters/excon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HttpLogHelper

#httplog_url

Instance Attribute Details

#bmObject (readonly)

Returns the value of attribute bm.



24
25
26
# File 'lib/httplog/adapters/excon.rb', line 24

def bm
  @bm
end

Instance Method Details

#orig_requestObject



26
# File 'lib/httplog/adapters/excon.rb', line 26

alias orig_request request

#request(params, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/httplog/adapters/excon.rb', line 27

def request(params, &block)
  result = nil
  bm = Benchmark.realtime do
    result = orig_request(params, &block)
  end

  url = httplog_url(@data)
  return result unless HttpLog.url_approved?(url)

  headers = result[:headers] || {}

  HttpLog.call(
    method: params[:method],
    url: url,
    request_body: @data[:body],
    request_headers: @data[:headers] || {},
    response_code: result[:status],
    response_body: result[:body],
    response_headers: headers,
    benchmark: bm,
    encoding: headers['Content-Encoding'],
    content_type: headers['Content-Type'],
    mask_body: HttpLog.masked_body_url?(url)
  )
  result
end