diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-10 21:52:38 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-10 21:52:38 -0600 |
commit | 5c4bd17d791d97310667acf6b458456aa1f8af0d (patch) | |
tree | f13ffb22bc1eefaa5085a5a7f46800af66f52dda | |
parent | 0f1bd2526b3972e131dccad32c7f7ea96a675880 (diff) | |
download | rack-5c4bd17d791d97310667acf6b458456aa1f8af0d.tar.gz |
Reverse hash for looking up status codes by symbol
-rw-r--r-- | lib/rack/utils.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb index 46362bab..333d8bf5 100644 --- a/lib/rack/utils.rb +++ b/lib/rack/utils.rb @@ -27,7 +27,7 @@ module Rack 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 @@ -394,6 +394,12 @@ module Rack # 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. |