1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Revert "use status code 303 for redirects"

This reverts commit c0eb84faa6.
This commit is contained in:
Konstantin Haase 2011-02-21 08:28:44 +01:00
parent 6d9d28215c
commit da5e3333be
3 changed files with 4 additions and 8 deletions

View file

@ -42,8 +42,6 @@
* Improved error handling. (cactus, Konstantin Haase) * Improved error handling. (cactus, Konstantin Haase)
* Use 303 instead of 302 for redirects. (Konstantin Haase)
* Skip missing template engines in tests correctly. (cactus) * Skip missing template engines in tests correctly. (cactus)
* Sinatra now ships with a Gemfile for development dependencies, since it eases * Sinatra now ships with a Gemfile for development dependencies, since it eases

View file

@ -95,9 +95,7 @@ module Sinatra
# Halt processing and redirect to the URI provided. # Halt processing and redirect to the URI provided.
def redirect(uri, *args) def redirect(uri, *args)
# Browsers treat 302 like 303, even though it should rather be handled status 302
# like 307. To show our good will, we use 303.
status 303
# According to RFC 2616 section 14.30, "the field value consists of a # According to RFC 2616 section 14.30, "the field value consists of a
# single absolute URI" # single absolute URI"

View file

@ -47,7 +47,7 @@ class HelpersTest < Test::Unit::TestCase
end end
describe 'redirect' do describe 'redirect' do
it 'uses a 303 when only a path is given' do it 'uses a 302 when only a path is given' do
mock_app { mock_app {
get '/' do get '/' do
redirect '/foo' redirect '/foo'
@ -56,7 +56,7 @@ class HelpersTest < Test::Unit::TestCase
} }
get '/' get '/'
assert_equal 303, status assert_equal 302, status
assert_equal '', body assert_equal '', body
assert_equal 'http://example.org/foo', response['Location'] assert_equal 'http://example.org/foo', response['Location']
end end
@ -84,7 +84,7 @@ class HelpersTest < Test::Unit::TestCase
request = Rack::MockRequest.new(@app) request = Rack::MockRequest.new(@app)
response = request.get('/try_redirect', 'HTTP_REFERER' => '/foo') response = request.get('/try_redirect', 'HTTP_REFERER' => '/foo')
assert_equal 303, response.status assert_equal 302, response.status
assert_equal 'http://example.org/foo', response['Location'] assert_equal 'http://example.org/foo', response['Location']
end end