Skip to content

Commit

Permalink
Reverse hash for looking up status codes by symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Dec 11, 2009
1 parent 0f1bd25 commit 5c4bd17
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/rack/utils.rb
Expand Up @@ -27,7 +27,7 @@ def unescape(s)
module_function :unescape

DEFAULT_SEP = /[&;] */n

# Stolen from Mongrel, with some small modifications:
# Parses a query string by breaking it up at the '&'
# and ';' characters. You can also use this to parse
Expand Down Expand Up @@ -394,6 +394,12 @@ 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 = HTTP_STATUS_CODES.inject({}) { |hash, (code, message)|
hash[message.downcase.gsub(/\s|-/, '_').to_sym] = code
hash
}


# A multipart form data parser, adapted from IOWA.
#
# Usually, Rack::Request#POST takes care of calling this.
Expand Down

0 comments on commit 5c4bd17

Please sign in to comment.