Skip to content

Commit

Permalink
Rack::Response::Helpers#redirect? would accept 308 status code
Browse files Browse the repository at this point in the history
308 status code is ‘Permanent Redirect’ (see
http://greenbytes.de/tech/webdav/draft-reschke-http-status-308-07.html)
and `Rack::Response::Helpers#redirect?` would accept it as a
redirection when 308 status is supported by Rack.
  • Loading branch information
deepj committed Aug 29, 2015
1 parent 9792bf5 commit 09b8271
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rack/response.rb
Expand Up @@ -129,7 +129,7 @@ def method_not_allowed?; status == 405; end
def precondition_failed?; status == 412; end
def unprocessable?; status == 422; end

def redirect?; [301, 302, 303, 307].include? status; end
def redirect?; [301, 302, 303, 307, 308].include? status; end

def include?(header)
have_header? header
Expand Down
15 changes: 12 additions & 3 deletions test/spec_response.rb
Expand Up @@ -241,6 +241,18 @@ def object_with_each.each
res.must_be :redirect?
res.must_be :moved_permanently?

res.status = 302
res.must_be :redirect?

res.status = 303
res.must_be :redirect?

res.status = 307
res.must_be :redirect?

res.status = 308
res.must_be :redirect?

res.status = 400
res.wont_be :successful?
res.must_be :client_error?
Expand Down Expand Up @@ -274,9 +286,6 @@ def object_with_each.each
res.status = 501
res.wont_be :successful?
res.must_be :server_error?

res.status = 307
res.must_be :redirect?
end

it "provide access to the HTTP headers" do
Expand Down

0 comments on commit 09b8271

Please sign in to comment.