1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-05 16:22:32 -04:00

Use 301 instead of 307

This commit is contained in:
Eduardo Gurgel 2014-01-30 11:20:59 -03:00
parent a82988e033
commit 059e60c3ca
2 changed files with 5 additions and 5 deletions

View file

@ -24,7 +24,7 @@ defmodule HTTParrot.RedirectHandler do
def resource_exists(req, state), do: {false, req, state}
def previously_existed(req, state), do: {true, req, state}
def moved_temporarily(req, n) do
def moved_permanently(req, n) do
{host_url, req} = :cowboy_req.host_url(req)
url = if n > 1, do: "/redirect/#{n-1}", else: "/get"
{{true, host_url <> url}, req, nil}

View file

@ -35,18 +35,18 @@ defmodule HTTParrot.RedirectHandlerTest do
assert validate :cowboy_req
end
test "moved_temporarily returns 'redirect/n-1' if n > 1" do
test "moved_permanently returns 'redirect/n-1' if n > 1" do
expect(:cowboy_req, :host_url, 1, {"host", :req2})
assert moved_temporarily(:req1, 4) == {{true, "host/redirect/3"}, :req2, nil}
assert moved_permanently(:req1, 4) == {{true, "host/redirect/3"}, :req2, nil}
assert validate :cowboy_req
end
test "moved_temporarily returns '/get' if n = 1" do
test "moved_permanently returns '/get' if n = 1" do
expect(:cowboy_req, :host_url, 1, {"host", :req2})
assert moved_temporarily(:req1, 1) == {{true, "host/get"}, :req2, nil}
assert moved_permanently(:req1, 1) == {{true, "host/get"}, :req2, nil}
assert validate :cowboy_req
end