documentation fixes & formatting #3
This commit is contained in:
parent
b21e64637f
commit
23278d651e
@ -695,16 +695,15 @@ get url = request $ do
|
|||||||
setUrl url
|
setUrl url
|
||||||
|
|
||||||
-- | Follow a redirect, if the last response was a redirect.
|
-- | Follow a redirect, if the last response was a redirect.
|
||||||
-- | (We consider a request a redirect if the status is
|
-- (We consider a request a redirect if the status is
|
||||||
-- | 301, 302, 303, 307 or 308, and the Location header is set.)
|
-- 301, 302, 303, 307 or 308, and the Location header is set.)
|
||||||
-- |
|
|
||||||
-- | Return Left with an error message if not a redirect
|
|
||||||
-- | Return Right with the redirected URL if it was.
|
|
||||||
--
|
--
|
||||||
-- ==== __Examples__
|
-- ==== __Examples__
|
||||||
--
|
--
|
||||||
-- > get HomeR
|
-- > get HomeR
|
||||||
-- > followRedirect
|
-- > followRedirect
|
||||||
|
followRedirect :: Yesod site
|
||||||
|
=> YesodExample site (Either T.Text T.Text) -- ^ 'Left' with an error message if not a redirect, 'Right' with the redirected URL if it was
|
||||||
followRedirect :: Yesod site
|
followRedirect :: Yesod site
|
||||||
=> YesodExample site (Either T.Text T.Text)
|
=> YesodExample site (Either T.Text T.Text)
|
||||||
followRedirect = do
|
followRedirect = do
|
||||||
@ -713,7 +712,7 @@ followRedirect = do
|
|||||||
Nothing -> return $ Left "followRedirect called, but there was no previous response, so no redirect to follow"
|
Nothing -> return $ Left "followRedirect called, but there was no previous response, so no redirect to follow"
|
||||||
Just r -> do
|
Just r -> do
|
||||||
if not ((H.statusCode $ simpleStatus r) `elem` [301, 302, 303, 307, 308])
|
if not ((H.statusCode $ simpleStatus r) `elem` [301, 302, 303, 307, 308])
|
||||||
then return $ Left "followRedirect called, but previous request was not a redirect"
|
then return $ Left "followRedirect called, but previous request was not a redirect"
|
||||||
else do
|
else do
|
||||||
case lookup "Location" (simpleHeaders r) of
|
case lookup "Location" (simpleHeaders r) of
|
||||||
Nothing -> return $ Left "followRedirect called, but no location header set"
|
Nothing -> return $ Left "followRedirect called, but no location header set"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user