Skip to content
Browse files

186 bro :'(

  • Loading branch information...
1 parent 511ee6f commit d3893c2709a9831f665245cf5da44e0019bead4f @raggi raggi committed
Showing with 10 additions and 10 deletions.
  1. +2 −2 lib/rack/auth/digest/params.rb
  2. +4 −4 lib/rack/request.rb
  3. +4 −4 lib/rack/utils.rb
View
4 lib/rack/auth/digest/params.rb
@@ -4,10 +4,10 @@ module Digest
class Params < Hash
def self.parse(str)
- Params[split_header_value(str).map do |param|
+ Params[*split_header_value(str).map do |param|
k, v = param.split('=', 2)
[k, dequote(v)]
- end]
+ end.flatten]
end
def self.dequote(str) # From WEBrick::HTTPUtils
View
8 lib/rack/request.rb
@@ -50,9 +50,9 @@ def media_type
# { 'charset' => 'utf-8' }
def media_type_params
return {} if content_type.nil?
- Hash[content_type.split(/\s*[;,]\s*/)[1..-1].
+ Hash[*content_type.split(/\s*[;,]\s*/)[1..-1].
collect { |s| s.split('=', 2) }.
- map { |k,v| [k.downcase, v] }]
+ map { |k,v| [k.downcase, v] }.flatten]
end
# The character set of the request body if a "charset" media type
@@ -212,9 +212,9 @@ def cookies
# precede those with less specific. Ordering with respect to other
# attributes (e.g., Domain) is unspecified.
@env["rack.request.cookie_hash"] =
- Hash[Utils.parse_query(@env["rack.request.cookie_string"], ';,').map {|k,v|
+ Hash[*Utils.parse_query(@env["rack.request.cookie_string"], ';,').map {|k,v|
[k, Array === v ? v.first : v]
- }]
+ }.flatten]
end
end
View
8 lib/rack/utils.rb
@@ -308,9 +308,9 @@ def each
end
def to_hash
- Hash[map do |k, v|
+ Hash[*map do |k, v|
[k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v]
- end]
+ end.flatten]
end
def [](k)
@@ -418,9 +418,9 @@ def replace(other)
# Responses with HTTP status codes that should not have an entity body
STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 304)
- SYMBOL_TO_STATUS_CODE = Hash[HTTP_STATUS_CODES.map { |code, message|
+ SYMBOL_TO_STATUS_CODE = Hash[*HTTP_STATUS_CODES.map { |code, message|
[message.downcase.gsub(/\s|-/, '_').to_sym, code]
- }]
+ }.flatten]
def status_code(status)
if status.is_a?(Symbol)

0 comments on commit d3893c2

Please sign in to comment.
Something went wrong with that request. Please try again.