Class: Honeybadger::Util::HTTP Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Logging::Helper
Defined in:
lib/honeybadger/util/http.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

HEADERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  'Content-type'.freeze => 'application/json'.freeze,
  'Content-Encoding'.freeze => 'deflate'.freeze,
  'Accept'.freeze => 'text/json, application/json'.freeze,
  'User-Agent'.freeze => "HB-Ruby #{VERSION}; #{RUBY_VERSION}; #{RUBY_PLATFORM}".freeze
}.freeze
ERRORS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[Timeout::Error,
Errno::EINVAL,
Errno::ECONNRESET,
Errno::ECONNREFUSED,
Errno::ENETUNREACH,
EOFError,
Net::HTTPBadResponse,
Net::HTTPHeaderSyntaxError,
Net::ProtocolError,
OpenSSL::SSL::SSLError,
SocketError].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ HTTP

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of HTTP.



36
37
38
# File 'lib/honeybadger/util/http.rb', line 36

def initialize(config)
  @config = config
end

Instance Method Details

#get(endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
43
44
# File 'lib/honeybadger/util/http.rb', line 40

def get(endpoint)
  response = http_connection.get(endpoint)
  debug { sprintf("http method=GET path=%s code=%d", endpoint.dump, response.code) }
  response
end

#post(endpoint, payload, headers = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
50
# File 'lib/honeybadger/util/http.rb', line 46

def post(endpoint, payload, headers = nil)
  response = http_connection.post(endpoint, compress(payload.to_json), http_headers(headers))
  debug { sprintf("http method=POST path=%s code=%d", endpoint.dump, response.code) }
  response
end

#post_newline_delimited(endpoint, payload, headers = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
55
56
# File 'lib/honeybadger/util/http.rb', line 52

def post_newline_delimited(endpoint, payload, headers = nil)
  response = http_connection.post(endpoint, compress(payload.map(&:to_json).join("\n")), http_headers(headers))
  debug { sprintf("http method=POST path=%s code=%d", endpoint.dump, response.code) }
  response
end