Sha256: 6e85d70b8a7e0217f91179658ddc0a94a4b7215cfe8a156a96a1fea719e76096

Contents?: true

Size: 1.07 KB

Versions: 320

Compression:

Stored size: 1.07 KB

Contents

module Rack
  module Auth
    module Digest
      class Params < Hash

        def self.parse(str)
          Params[*split_header_value(str).map do |param|
            k, v = param.split('=', 2)
            [k, dequote(v)]
          end.flatten]
        end

        def self.dequote(str) # From WEBrick::HTTPUtils
          ret = (/\A"(.*)"\Z/ =~ str) ? $1 : str.dup
          ret.gsub!(/\\(.)/, "\\1")
          ret
        end

        def self.split_header_value(str)
          str.scan( /(\w+\=(?:"[^\"]+"|[^,]+))/n ).collect{ |v| v[0] }
        end

        def initialize
          super()

          yield self if block_given?
        end

        def [](k)
          super k.to_s
        end

        def []=(k, v)
          super k.to_s, v.to_s
        end

        UNQUOTED = ['nc', 'stale']

        def to_s
          map do |k, v|
            "#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v))
          end.join(', ')
        end

        def quote(str) # From WEBrick::HTTPUtils
          '"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
        end

      end
    end
  end
end

Version data entries

320 entries across 277 versions & 55 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/rack-1.6.6/lib/rack/auth/digest/params.rb