Class: Datadog::CI::Transport::HTTP
- Inherits:
-
Object
- Object
- Datadog::CI::Transport::HTTP
- Defined in:
- lib/datadog/ci/transport/http.rb
Defined Under Namespace
Classes: ResponseDecorator
Constant Summary collapse
- DEFAULT_TIMEOUT =
30
Instance Attribute Summary collapse
-
#compress ⇒ Object
readonly
Returns the value of attribute compress.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(host:, timeout: DEFAULT_TIMEOUT, port: nil, ssl: true, compress: false) ⇒ HTTP
constructor
A new instance of HTTP.
- #request(path:, payload:, headers:, verb: "post") ⇒ Object
Constructor Details
#initialize(host:, timeout: DEFAULT_TIMEOUT, port: nil, ssl: true, compress: false) ⇒ HTTP
Returns a new instance of HTTP.
24 25 26 27 28 29 30 |
# File 'lib/datadog/ci/transport/http.rb', line 24 def initialize(host:, timeout: DEFAULT_TIMEOUT, port: nil, ssl: true, compress: false) @host = host @port = port @timeout = timeout @ssl = ssl.nil? ? true : ssl @compress = compress.nil? ? false : compress end |
Instance Attribute Details
#compress ⇒ Object (readonly)
Returns the value of attribute compress.
15 16 17 |
# File 'lib/datadog/ci/transport/http.rb', line 15 def compress @compress end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
15 16 17 |
# File 'lib/datadog/ci/transport/http.rb', line 15 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
15 16 17 |
# File 'lib/datadog/ci/transport/http.rb', line 15 def port @port end |
#ssl ⇒ Object (readonly)
Returns the value of attribute ssl.
15 16 17 |
# File 'lib/datadog/ci/transport/http.rb', line 15 def ssl @ssl end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
15 16 17 |
# File 'lib/datadog/ci/transport/http.rb', line 15 def timeout @timeout end |
Instance Method Details
#request(path:, payload:, headers:, verb: "post") ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/datadog/ci/transport/http.rb', line 32 def request(path:, payload:, headers:, verb: "post") if compress headers[Ext::Transport::HEADER_CONTENT_ENCODING] = Ext::Transport::CONTENT_ENCODING_GZIP payload = Gzip.compress(payload) end Datadog.logger.debug do "Sending #{verb} request: host=#{host}; port=#{port}; ssl_enabled=#{ssl}; " \ "compression_enabled=#{compress}; path=#{path}; payload_size=#{payload.size}" end ResponseDecorator.new( adapter.call( build_env(path: path, payload: payload, headers: headers, verb: verb) ) ) end |