Sha256: 8306db17228a60d0d10f5d92d15286cf1a355159bfb4383dbb64ca7a2a857ecb

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module NewRelic
  module Agent
    module HTTPClients
      class HTTPResponse
        attr_reader :response

        def initialize(response)
          @response = response
        end

        def [](key)
          _, value = response.headers.find { |k,_| key.downcase == k.downcase }
          value unless value.nil?
        end

        def to_hash
          response.headers
        end
      end

      class HTTPRequest
        attr_reader :request, :uri

        def initialize(request)
          @request = request
          @uri = request.uri
        end

        def type
          "http.rb"
        end

        def host
          if hostname = self['host']
            hostname.split(':').first
          else
            request.host
          end
        end

        def method
          request.verb.upcase
        end

        def [](key)
          request.headers[key]
        end

        def []=(key, value)
          request.headers[key] = value
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
newrelic_rpm-3.17.2.327 lib/new_relic/agent/http_clients/http_rb_wrappers.rb
newrelic_rpm-3.17.1.326 lib/new_relic/agent/http_clients/http_rb_wrappers.rb
newrelic_rpm-3.17.0.325 lib/new_relic/agent/http_clients/http_rb_wrappers.rb
newrelic_rpm-3.16.3.323 lib/new_relic/agent/http_clients/http_rb_wrappers.rb