Sha256: 074b7c071324bc9b9ba3937446f36554a3e0564baa5057170c9004b0fc753dea

Contents?: true

Size: 1.53 KB

Versions: 23

Compression:

Stored size: 1.53 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_url(url)
          if defined?(::Addressable::URI)
            address = ::Addressable::URI.parse(url)
            address.normalize!
            URI.parse(address.to_s)
          else
            URI.parse(url)
          end
        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

23 entries across 23 versions & 2 rubygems

Version Path
newrelic_rpm-4.0.0.332 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.18.1.330 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.18.0.329 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.17.2.327 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.17.1.326 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.17.0.325 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.16.3.323 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.16.2.321 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.16.1.320 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.16.0.318 lib/new_relic/agent/http_clients/uri_util.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.15.2.317 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.15.1.316 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.15.0.314 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.14.3.313 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.14.2.312 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.14.1.311 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.14.0.305 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.13.2.302 lib/new_relic/agent/http_clients/uri_util.rb
newrelic_rpm-3.13.1.300 lib/new_relic/agent/http_clients/uri_util.rb