Sha256: 558a4c59d2581628904e48c3c86221349e6baefee6053ab53beb1f3352cb6156

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 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 NetHTTPRequest
        def initialize(connection, request)
          @connection = connection
          @request = request
        end

        NET_HTTP = 'Net::HTTP'.freeze

        def type
          NET_HTTP
        end

        HOST = 'host'.freeze
        COLON = ':'.freeze

        def host_from_header
          if hostname = self[HOST]
            hostname.split(COLON).first
          end
        end

        def host
          host_from_header || @connection.address
        end

        def method
          @request.method
        end

        def [](key)
          @request[key]
        end

        def []=(key, value)
          @request[key] = value
        end

        def uri
          case @request.path
          when /^https?:\/\//
            URI(@request.path)
          else
            scheme = @connection.use_ssl? ? 'https' : 'http'
            URI("#{scheme}://#{@connection.address}:#{@connection.port}#{@request.path}")
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
newrelic_rpm-4.5.0.337 lib/new_relic/agent/http_clients/net_http_wrappers.rb
newrelic_rpm-4.4.0.336 lib/new_relic/agent/http_clients/net_http_wrappers.rb
newrelic_rpm-4.3.0.335 lib/new_relic/agent/http_clients/net_http_wrappers.rb
newrelic_rpm-4.2.0.334 lib/new_relic/agent/http_clients/net_http_wrappers.rb
newrelic_rpm-4.1.0.333 lib/new_relic/agent/http_clients/net_http_wrappers.rb
newrelic_rpm-4.0.0.332 lib/new_relic/agent/http_clients/net_http_wrappers.rb
newrelic_rpm-3.18.1.330 lib/new_relic/agent/http_clients/net_http_wrappers.rb
newrelic_rpm-3.18.0.329 lib/new_relic/agent/http_clients/net_http_wrappers.rb