Class: Datadog::CI::Transport::HTTP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/transport/http.rb

Overview

Data structure for an HTTP Response

Direct Known Subclasses

InternalErrorResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ Response

Returns a new instance of Response.



75
76
77
# File 'lib/datadog/ci/transport/http.rb', line 75

def initialize(http_response)
  @http_response = http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



73
74
75
# File 'lib/datadog/ci/transport/http.rb', line 73

def http_response
  @http_response
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/datadog/ci/transport/http.rb', line 99

def client_error?
  code.between?(400, 499)
end

#codeObject



83
84
85
# File 'lib/datadog/ci/transport/http.rb', line 83

def code
  http_response.code.to_i
end

#inspectObject



115
116
117
118
119
120
# File 'lib/datadog/ci/transport/http.rb', line 115

def inspect
  "#{self.class} ok?:#{ok?} unsupported?:#{unsupported?}, " \
  "not_found?:#{not_found?}, client_error?:#{client_error?}, " \
  "server_error?:#{server_error?}, internal_error?:#{internal_error?}, " \
  "payload:#{payload}"
end

#internal_error?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/datadog/ci/transport/http.rb', line 107

def internal_error?
  false
end

#not_found?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/datadog/ci/transport/http.rb', line 95

def not_found?
  code == 404
end

#ok?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/datadog/ci/transport/http.rb', line 87

def ok?
  code.between?(200, 299)
end

#payloadObject



79
80
81
# File 'lib/datadog/ci/transport/http.rb', line 79

def payload
  http_response.body
end

#server_error?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/datadog/ci/transport/http.rb', line 103

def server_error?
  code.between?(500, 599)
end

#trace_countObject



111
112
113
# File 'lib/datadog/ci/transport/http.rb', line 111

def trace_count
  0
end

#unsupported?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/datadog/ci/transport/http.rb', line 91

def unsupported?
  code == 415
end