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

Inherits:
Object
  • Object
show all
Includes:
Response
Defined in:
lib/datadog/core/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.



113
114
115
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 113

def initialize(http_response)
  @http_response = http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



111
112
113
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 111

def http_response
  @http_response
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


147
148
149
150
151
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 147

def client_error?
  return super if http_response.nil?

  code.between?(400, 499)
end

#codeObject



123
124
125
126
127
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 123

def code
  return super if http_response.nil?

  http_response.code.to_i
end

#inspectObject



159
160
161
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 159

def inspect
  "#{super}, http_response:#{http_response}"
end

#not_found?Boolean

Returns:

  • (Boolean)


141
142
143
144
145
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 141

def not_found?
  return super if http_response.nil?

  code == 404
end

#ok?Boolean

Returns:

  • (Boolean)


129
130
131
132
133
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 129

def ok?
  return super if http_response.nil?

  code.between?(200, 299)
end

#payloadObject



117
118
119
120
121
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 117

def payload
  return super if http_response.nil?

  http_response.body
end

#server_error?Boolean

Returns:

  • (Boolean)


153
154
155
156
157
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 153

def server_error?
  return super if http_response.nil?

  code.between?(500, 599)
end

#unsupported?Boolean

Returns:

  • (Boolean)


135
136
137
138
139
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 135

def unsupported?
  return super if http_response.nil?

  code == 415
end