Use 303 for HTTP/1.1 (#217)
This commit is contained in:
parent
895bb7666b
commit
7aa5c02c35
@ -455,7 +455,13 @@ safeEh er = YesodApp $ \_ _ _ session -> do
|
|||||||
-- a 302. If at some future date it is determined that virtually all clients
|
-- a 302. If at some future date it is determined that virtually all clients
|
||||||
-- understand 303, this implementation will switch to that status code.
|
-- understand 303, this implementation will switch to that status code.
|
||||||
redirect :: RedirectUrl master url => url -> GHandler sub master a
|
redirect :: RedirectUrl master url => url -> GHandler sub master a
|
||||||
redirect = redirectWith H.status302
|
redirect url = do
|
||||||
|
req <- waiRequest
|
||||||
|
let status =
|
||||||
|
if W.httpVersion req == H.http11
|
||||||
|
then H.status303
|
||||||
|
else H.status302
|
||||||
|
redirectWith status url
|
||||||
|
|
||||||
-- | Redirect to the given URL with the specified status code.
|
-- | Redirect to the given URL with the specified status code.
|
||||||
redirectWith :: RedirectUrl master url => H.Status -> url -> GHandler sub master a
|
redirectWith :: RedirectUrl master url => H.Status -> url -> GHandler sub master a
|
||||||
|
|||||||
@ -43,10 +43,17 @@ specs = describe "Redirect" [
|
|||||||
assertStatus 307 res
|
assertStatus 307 res
|
||||||
assertBodyContains "" res
|
assertBodyContains "" res
|
||||||
|
|
||||||
, it "302 redirect for regular" $ app $ do
|
, it "303 redirect for regular, HTTP 1.1" $ app $ do
|
||||||
res <- request defaultRequest {
|
res <- request defaultRequest {
|
||||||
pathInfo = ["rregular"]
|
pathInfo = ["rregular"]
|
||||||
}
|
}
|
||||||
|
assertStatus 303 res
|
||||||
|
assertBodyContains "" res
|
||||||
|
, it "302 redirect for regular, HTTP 1.0" $ app $ do
|
||||||
|
res <- request defaultRequest {
|
||||||
|
pathInfo = ["rregular"]
|
||||||
|
, httpVersion = H.http10
|
||||||
|
}
|
||||||
assertStatus 302 res
|
assertStatus 302 res
|
||||||
assertBodyContains "" res
|
assertBodyContains "" res
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user