Sha256: b5b6c5f958f0fb169ea53631c7eacc9bd657775b7d4c56768e9bfadaef41a644

Contents?: true

Size: 1.7 KB

Versions: 25

Compression:

Stored size: 1.7 KB

Contents

# -*- ruby -*-
# 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.

# This module includes utilities for manipulating URIs, particularly from the
# context of Net::HTTP requests. We don't always have direct access to the full
# URI from our instrumentation points in Net::HTTP, and we want to filter out
# some URI parts before saving URIs from instrumented calls - logic for that
# lives here.

module NewRelic
  module Agent
    module HTTPClients
      module URIUtil

        def self.filter_uri(original)
          filtered = original.dup
          filtered.user = nil
          filtered.password = nil
          filtered.query = nil
          filtered.fragment = nil
          filtered.to_s
        end

        # There are valid URI strings that some HTTP client libraries will
        # accept that the stdlib URI module doesn't handle. If we find that
        # Addressable is around, use that to normalize out our URL's.
        def self.parse_and_normalize_url(url)
          uri = url
          unless ::URI === uri
            if defined?(::Addressable::URI)
              address = ::Addressable::URI.parse(url)
              address.normalize!
              uri = ::URI.parse(address.to_s)
            else
              uri = ::URI.parse(url)
            end
          end
          uri.host.downcase! unless uri.host.nil?
          uri
        end

        QUESTION_MARK = "?".freeze

        def self.strip_query_string(fragment)
          if(fragment.include?(QUESTION_MARK))
            fragment.split(QUESTION_MARK).first
          else
            fragment
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
newrelic_rpm-6.9.0.363 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.8.0.360 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.7.0.359 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.6.0.358 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.5.0.357 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.4.0.356 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.3.0.355 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.2.0.354 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.1.0.352 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-6.0.0.351 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.7.0.350 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.6.0.349 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.5.0.348 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.4.0.347 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.1.0.344 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-5.0.0.342 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-4.8.0.341 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-4.7.1.340 lib/new_relic/agent/http_clients/uri_util.rb