Sha256: b742076bbfe755f9076cf3ea69144d45770955eb5bd17c14ccf8b4666bc4d794

Contents?: true

Size: 1.04 KB

Versions: 46

Compression:

Stored size: 1.04 KB

Contents

module Airbrake
  module Rack
    # Adds HTTP request parameters.
    #
    # @since v5.7.0
    class HttpHeadersFilter
      # @return [Array<String>] the prefixes of the majority of HTTP headers in
      #   Rack (some prefixes match the header names for simplicity)
      HTTP_HEADER_PREFIXES = [
        'HTTP_'.freeze,
        'CONTENT_TYPE'.freeze,
        'CONTENT_LENGTH'.freeze
      ].freeze

      # @return [Integer]
      attr_reader :weight

      def initialize
        @weight = 98
      end

      # @see Airbrake::FilterChain#refine
      def call(notice)
        return unless (request = notice.stash[:rack_request])

        http_headers = request.env.map.with_object({}) do |(key, value), headers|
          if HTTP_HEADER_PREFIXES.any? { |prefix| key.to_s.start_with?(prefix) }
            headers[key] = value
          end

          headers
        end

        notice[:context].merge!(
          httpMethod: request.request_method,
          referer: request.referer,
          headers: http_headers
        )
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
airbrake-9.5.5 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.5.4 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.5.3 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.5.2 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.5.1 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.5.0 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.4.5 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.4.4 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.4.3 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.4.2 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.4.1 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.4.0 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.3.0 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.2.2 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.2.1 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.2.0 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.1.0 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.0.2 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.0.1 lib/airbrake/rack/http_headers_filter.rb
airbrake-9.0.0 lib/airbrake/rack/http_headers_filter.rb