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.



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

def initialize(http_response)
  @http_response = http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



102
103
104
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 102

def http_response
  @http_response
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


138
139
140
141
142
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 138

def client_error?
  return super if http_response.nil?

  code.between?(400, 499)
end

#codeObject



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

def code
  return super if http_response.nil?

  http_response.code.to_i
end

#inspectObject



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

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

#not_found?Boolean

Returns:

  • (Boolean)


132
133
134
135
136
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 132

def not_found?
  return super if http_response.nil?

  code == 404
end

#ok?Boolean

Returns:

  • (Boolean)


120
121
122
123
124
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 120

def ok?
  return super if http_response.nil?

  code.between?(200, 299)
end

#payloadObject



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

def payload
  return super if http_response.nil?

  http_response.body
end

#server_error?Boolean

Returns:

  • (Boolean)


144
145
146
147
148
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 144

def server_error?
  return super if http_response.nil?

  code.between?(500, 599)
end

#unsupported?Boolean

Returns:

  • (Boolean)


126
127
128
129
130
# File 'lib/datadog/core/transport/http/adapters/net.rb', line 126

def unsupported?
  return super if http_response.nil?

  code == 415
end