Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add support for RFC2324 #667

Merged
merged 2 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 8, 2014
  1. @mattkasa
  2. @mattkasa

    Add helper method for 418

    mattkasa authored
This page is out of date. Refresh to see the latest.
View
1  lib/rack/response.rb
@@ -129,6 +129,7 @@ def unauthorized?; status == 401; end
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
View
3  lib/rack/utils.rb
@@ -587,6 +587,7 @@ def to_params_hash
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 @@ def to_params_hash
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)
View
5 test/spec_response.rb
@@ -251,6 +251,11 @@ def object_with_each.each
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
Something went wrong with that request. Please try again.