Class: Datadog::Core::Telemetry::Http::Adapters::Net::Response

Inherits:
Object
  • Object
show all
Includes:
Response
Defined in:
lib/datadog/core/telemetry/http/adapters/net.rb

Overview

Data structure for an HTTP Response

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.



56
57
58
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 56

def initialize(http_response)
  @http_response = http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



54
55
56
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 54

def http_response
  @http_response
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


90
91
92
93
94
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 90

def client_error?
  return super if http_response.nil?

  code.between?(400, 499)
end

#codeObject



66
67
68
69
70
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 66

def code
  return super if http_response.nil?

  http_response.code.to_i
end

#inspectObject



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

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

#not_found?Boolean

Returns:

  • (Boolean)


84
85
86
87
88
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 84

def not_found?
  return super if http_response.nil?

  code == 404
end

#ok?Boolean

Returns:

  • (Boolean)


72
73
74
75
76
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 72

def ok?
  return super if http_response.nil?

  code.between?(200, 299)
end

#payloadObject



60
61
62
63
64
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 60

def payload
  return super if http_response.nil?

  http_response.body
end

#server_error?Boolean

Returns:

  • (Boolean)


96
97
98
99
100
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 96

def server_error?
  return super if http_response.nil?

  code.between?(500, 599)
end

#unsupported?Boolean

Returns:

  • (Boolean)


78
79
80
81
82
# File 'lib/datadog/core/telemetry/http/adapters/net.rb', line 78

def unsupported?
  return super if http_response.nil?

  code == 415
end