Class: OneApm::Support::HTTPClients::ExconHTTPRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/one_apm/support/http_clients/excon_wrappers.rb

Instance Method Summary collapse

Constructor Details

#initialize(datum) ⇒ ExconHTTPRequest

Returns a new instance of ExconHTTPRequest.



28
29
30
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 28

def initialize(datum)
  @datum = datum
end

Instance Method Details

#[](key) ⇒ Object



57
58
59
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 57

def [](key)
  @datum[:headers][key]
end

#[]=(key, value) ⇒ Object



61
62
63
64
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 61

def []=(key, value)
  @datum[:headers] ||= {}
  @datum[:headers][key] = value
end

#bodyObject



74
75
76
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 74

def body
  @datum[:body]
end

#hostObject



36
37
38
39
40
41
42
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 36

def host
  if hostname = (self['host'] || self['Host'])
    hostname.split(':').first
  else
    @datum[:host]
  end
end

#methodObject



53
54
55
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 53

def method
  @datum[:method].to_s.upcase
end

#paramsObject



82
83
84
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 82

def params
  post_params.merge(query)
end

#portObject



44
45
46
47
48
49
50
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 44

def port
  if hostname = (self['host'] || self['Host'])
    hostname.split(':').last
  else
    @datum[:port]
  end
end

#post_paramsObject



78
79
80
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 78

def post_params
  body.nil?? {} :  CGI.parse(body)
end

#queryObject



70
71
72
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 70

def query
  uri.query.nil?? {} : CGI.parse(uri.query)
end

#typeObject



32
33
34
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 32

def type
  "Excon"
end

#uriObject



66
67
68
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 66

def uri
  URI.parse("#{@datum[:scheme]}://#{@datum[:host]}:#{@datum[:port]}#{@datum[:path]}")
end