Merge pull request #78 from MakeNowJust/patch-1

Use 302 to redirect instead of 301
This commit is contained in:
Serdar Dogruyol 2016-02-09 18:02:41 +02:00
commit 70ef8a7718
2 changed files with 3 additions and 3 deletions

View file

@ -204,7 +204,7 @@ describe "Kemal::RouteHandler" do
request = HTTP::Request.new("GET", "/")
io_with_context = create_request_and_return_io(kemal, request)
client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false)
client_response.status_code.should eq(301)
client_response.status_code.should eq(302)
client_response.headers.has_key?("Location").should eq(true)
end
end

View file

@ -8,9 +8,9 @@ class HTTP::Server
Kemal::ParamParser.new(@route, @request).parse
end
def redirect(url)
def redirect(url, status_code = 302)
@response.headers.add "Location", url
@response.status_code = 301
@response.status_code = status_code
end
end
end