Sha256: 6602776a88f28d9863dce07300b1cb1e14e139d192db529edcb273b6ee5db4e4

Contents?: true

Size: 824 Bytes

Versions: 6

Compression:

Stored size: 824 Bytes

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

# In earlier versions of rack < 2.0.0 the Rack::Response and Rack::Request do
# not have get_header or set_header methods. This is our way of working
# around that.
module Rack
  # Our patch into the Rack::Request class, allowing us to call set_header
  # and get_header in our code without worrying about older versions of
  # Rack not implementing these methods.
  class Request
    unless Rack::Request.instance_methods(true).include?(:set_header)
      def set_header name, value
        @env[name] = value
      end
    end

    unless Rack::Request.instance_methods(true).include?(:get_header)
      def get_header name
        @env[name]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-3.11.0 lib/contrast/extensions/framework/rack/request.rb
contrast-agent-3.10.2 lib/contrast/extensions/framework/rack/request.rb
contrast-agent-3.10.1 lib/contrast/extensions/framework/rack/request.rb
contrast-agent-3.10.0 lib/contrast/extensions/framework/rack/request.rb
contrast-agent-3.9.1 lib/contrast/extensions/framework/rack/request.rb
contrast-agent-3.9.0 lib/contrast/extensions/framework/rack/request.rb