summary refs log tree commit
diff options
context:
space:
mode:
authorJames Tucker <jftucker@gmail.com>2014-07-05 16:48:54 -0700
committerJames Tucker <jftucker@gmail.com>2014-07-05 16:48:54 -0700
commit370e34a2f23c6ccf883c749de435aa8c7b60941e (patch)
treed05ca2f5f6f8d32886e6b19865f1d226fa2b104a
parent50819562e647b0e3c76fd58ebb9fb0f92d14beef (diff)
parentd71053f2f3734326336020f669641d56e821b734 (diff)
downloadrack-370e34a2f23c6ccf883c749de435aa8c7b60941e.tar.gz
Merge pull request #667 from mattkasa/feature/add_rfc2324_status_code
Add support for RFC2324
-rw-r--r--lib/rack/response.rb1
-rw-r--r--lib/rack/utils.rb3
-rw-r--r--test/spec_response.rb5
3 files changed, 8 insertions, 1 deletions
diff --git a/lib/rack/response.rb b/lib/rack/response.rb
index bd39da3b..12536710 100644
--- a/lib/rack/response.rb
+++ b/lib/rack/response.rb
@@ -129,6 +129,7 @@ module Rack
       def forbidden?;          status == 403;                        end
       def not_found?;          status == 404;                        end
       def method_not_allowed?; status == 405;                        end
+      def i_m_a_teapot?;       status == 418;                        end
       def unprocessable?;      status == 422;                        end
 
       def redirect?;           [301, 302, 303, 307].include? status; end
diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb
index 6c2bf907..28e0ded6 100644
--- a/lib/rack/utils.rb
+++ b/lib/rack/utils.rb
@@ -587,6 +587,7 @@ module Rack
       415 => 'Unsupported Media Type',
       416 => 'Requested Range Not Satisfiable',
       417 => 'Expectation Failed',
+      418 => 'I\'m a teapot',
       422 => 'Unprocessable Entity',
       423 => 'Locked',
       424 => 'Failed Dependency',
@@ -611,7 +612,7 @@ module Rack
     STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 205 << 304)
 
     SYMBOL_TO_STATUS_CODE = Hash[*HTTP_STATUS_CODES.map { |code, message|
-      [message.downcase.gsub(/\s|-/, '_').to_sym, code]
+      [message.downcase.gsub(/\s|-|'/, '_').to_sym, code]
     }.flatten]
 
     def status_code(status)
diff --git a/test/spec_response.rb b/test/spec_response.rb
index 031488bb..6b13c0c9 100644
--- a/test/spec_response.rb
+++ b/test/spec_response.rb
@@ -251,6 +251,11 @@ describe Rack::Response do
     res.should.be.client_error
     res.should.be.method_not_allowed
 
+    res.status = 418
+    res.should.not.be.successful
+    res.should.be.client_error
+    res.should.be.i_m_a_teapot
+
     res.status = 422
     res.should.not.be.successful
     res.should.be.client_error