# File lib/rack/auth/digest/params.rb, line 14 def self.dequote(str) # From WEBrick::HTTPUtils ret = (%r\A"(.*)"\Z/ =~ str) ? $1 : str.dup ret.gsub!(%r\\(.)/, "\\1") ret end
# File lib/rack/auth/digest/params.rb, line 24 def initialize super() yield self if block_given? end
# File lib/rack/auth/digest/params.rb, line 6 def self.parse(str) split_header_value(str).inject(new) do |header, param| k, v = param.split('=', 2) header[k] = dequote(v) header end end
# File lib/rack/auth/digest/params.rb, line 20 def self.split_header_value(str) str.scan( %r(\w+\=(?:"[^\"]+"|[^,]+))/ ).collect{ |v| v[0] } end
# File lib/rack/auth/digest/params.rb, line 30 def [](k) super k.to_s end
# File lib/rack/auth/digest/params.rb, line 34 def []=(k, v) super k.to_s, v.to_s end
# File lib/rack/auth/digest/params.rb, line 47 def quote(str) # From WEBrick::HTTPUtils '"' << str.gsub(%r[\\\"]/, "\\\11"") << '"' end
# File lib/rack/auth/digest/params.rb, line 40 def to_s inject([]) do |parts, (k, v)| parts << "#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v)) parts end.join(', ') end