Class: Datadog::CI::Transport::HTTP::ResponseDecorator

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

Overview

adds compatibility with Datadog::Tracing transport and provides ungzipping capabilities

Instance Method Summary collapse

Instance Method Details

#gzipped?(payload) ⇒ Boolean

Returns:

  • (Boolean)


124
125
126
127
128
129
130
131
# File 'lib/datadog/ci/transport/http.rb', line 124

def gzipped?(payload)
  return false if payload.nil? || payload.empty?

  first_bytes = payload[0, 2]
  return false if first_bytes.nil? || first_bytes.empty?

  first_bytes.b == Datadog::CI::Ext::Transport::GZIP_MAGIC_NUMBER
end

#payloadObject



109
110
111
112
113
114
115
116
117
118
# File 'lib/datadog/ci/transport/http.rb', line 109

def payload
  return @decompressed_payload if defined?(@decompressed_payload)

  if gzipped?(__getobj__.payload)
    Datadog.logger.debug("Decompressing gzipped response payload")
    @decompressed_payload = Gzip.decompress(__getobj__.payload)
  else
    __getobj__.payload
  end
end

#trace_countObject



120
121
122
# File 'lib/datadog/ci/transport/http.rb', line 120

def trace_count
  0
end