Class: Datadog::Transport::HTTP::Adapters::Net::Response

Inherits:
Object
  • Object
show all
Includes:
Response
Defined in:
lib/ddtrace/transport/http/adapters/net.rb

Overview

A wrapped Net::HTTP response that implements the Transport::Response interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Response

#internal_error?

Constructor Details

#initialize(http_response) ⇒ Response

Returns a new instance of Response.



69
70
71
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 69

def initialize(http_response)
  @http_response = http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



67
68
69
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 67

def http_response
  @http_response
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


98
99
100
101
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 98

def client_error?
  return super if http_response.nil?
  code.between?(400, 499)
end

#codeObject



78
79
80
81
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 78

def code
  return super if http_response.nil?
  http_response.code.to_i
end

#not_found?Boolean

Returns:

  • (Boolean)


93
94
95
96
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 93

def not_found?
  return super if http_response.nil?
  code == 404
end

#ok?Boolean

Returns:

  • (Boolean)


83
84
85
86
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 83

def ok?
  return super if http_response.nil?
  code.between?(200, 299)
end

#payloadObject



73
74
75
76
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 73

def payload
  return super if http_response.nil?
  http_response.body
end

#server_error?Boolean

Returns:

  • (Boolean)


103
104
105
106
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 103

def server_error?
  return super if http_response.nil?
  code.between?(500, 599)
end

#unsupported?Boolean

Returns:

  • (Boolean)


88
89
90
91
# File 'lib/ddtrace/transport/http/adapters/net.rb', line 88

def unsupported?
  return super if http_response.nil?
  code == 415
end