Sha256: 8530f60fc7348bbd1ece04345ecf3e93c11133238c43559203f853ac5898907a

Contents?: true

Size: 1.57 KB

Versions: 13

Compression:

Stored size: 1.57 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require_relative 'abstract'

module NewRelic
  module Agent
    module HTTPClients
      class CurbRequest < AbstractRequest
        CURB = 'Curb'

        def initialize(curlobj)
          @curlobj = curlobj
        end

        def type
          CURB
        end

        def host_from_header
          self[LHOST] || self[UHOST]
        end

        def host
          host_from_header || self.uri.host
        end

        def method
          @curlobj._nr_http_verb
        end

        def [](key)
          headers[key]
        end

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

        def uri
          @uri ||= URIUtil.parse_and_normalize_url(@curlobj.url)
        end

        def headers
          @curlobj.headers
        end
      end

      class CurbResponse < AbstractResponse
        def initialize(wrapped_response)
          super(wrapped_response)
          @headers = {}
        end

        def [](key)
          @headers[key.downcase]
        end

        def to_hash
          @headers.dup
        end

        def append_header_data(data)
          key, value = data.split(/:\s*/, 2)
          @headers[key.downcase] = value
          @wrapped_response._nr_header_str ||= +''
          @wrapped_response._nr_header_str << data
        end

        private

        def get_status_code
          get_status_code_using(:response_code)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
newrelic_rpm-9.16.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/http_clients/curb_wrappers.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/http_clients/curb_wrappers.rb