mirror of
https://github.com/serokell/xrefcheck.git
synced 2024-09-11 13:37:36 +03:00
[#25] Handle 304 redirect
Problem: After recent work on Xrefcheck redirect behavior, it remained to discuss how to handle 304 redirects. Solution: With the current default configuration, 304 redirects are considered as valid, which seems appropriate taking into account that 304 responses usually mean that you previously received a successful response for that same request and there is no need to retransmit the resource again. We add a test case for this default config and update the FAQ section.
This commit is contained in:
parent
20f3d052e0
commit
eccb6d0068
@ -143,7 +143,7 @@ There are several ways to fix this:
|
|||||||
1. How does `xrefcheck` handle redirects?
|
1. How does `xrefcheck` handle redirects?
|
||||||
* The rules from the default configuration are as follows:
|
* The rules from the default configuration are as follows:
|
||||||
* Permanent redirects (i.e. 301 and 308) are reported as errors.
|
* Permanent redirects (i.e. 301 and 308) are reported as errors.
|
||||||
* Temporary redirects (i.e. 302, 303 and 307) are assumed to be valid.
|
* There are no rules for other redirects, except for a special GitLab case, so they are assumed to be valid.
|
||||||
* Redirect rules can be specified with the `externalRefRedirects` parameter within `networking`, which accepts an array of
|
* Redirect rules can be specified with the `externalRefRedirects` parameter within `networking`, which accepts an array of
|
||||||
rules with keys `from`, `to`, `on` and `outcome`. The rule applied is the first one that matches with
|
rules with keys `from`, `to`, `on` and `outcome`. The rule applied is the first one that matches with
|
||||||
the `from`, `to` and `on` fields, if any, where
|
the `from`, `to` and `on` fields, if any, where
|
||||||
|
@ -23,8 +23,9 @@ import Xrefcheck.Verify
|
|||||||
|
|
||||||
test_redirectRequests :: TestTree
|
test_redirectRequests :: TestTree
|
||||||
test_redirectRequests = testGroup "Redirect response defaults"
|
test_redirectRequests = testGroup "Redirect response defaults"
|
||||||
[ testGroup "Temporary" $ temporaryRedirectTests <$> [302, 303, 307]
|
[ testGroup "Temporary" $ allowedRedirectTests <$> [302, 303, 307]
|
||||||
, testGroup "Permanent" $ permanentRedirectTests <$> [301, 308]
|
, testGroup "Permanent" $ permanentRedirectTests <$> [301, 308]
|
||||||
|
, testGroup "304 Not Modified" $ allowedRedirectTests <$> [304]
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
url :: Text
|
url :: Text
|
||||||
@ -33,11 +34,11 @@ test_redirectRequests = testGroup "Redirect response defaults"
|
|||||||
location :: Maybe Text
|
location :: Maybe Text
|
||||||
location = Just "http://127.0.0.1:5000/other"
|
location = Just "http://127.0.0.1:5000/other"
|
||||||
|
|
||||||
temporaryRedirectTests :: Int -> TestTree
|
allowedRedirectTests :: Int -> TestTree
|
||||||
temporaryRedirectTests statusCode =
|
allowedRedirectTests statusCode =
|
||||||
redirectTests
|
redirectTests
|
||||||
(show statusCode <> " passes by default")
|
(show statusCode <> " passes by default")
|
||||||
(mkStatus statusCode "Temporary redirect")
|
(mkStatus statusCode "Allowed redirect")
|
||||||
(\case
|
(\case
|
||||||
Nothing -> Just $ RedirectMissingLocation $ fromList [url]
|
Nothing -> Just $ RedirectMissingLocation $ fromList [url]
|
||||||
Just _ -> Nothing
|
Just _ -> Nothing
|
||||||
|
Loading…
Reference in New Issue
Block a user