Skip to content

Commit

Permalink
[#25] Handle 304 redirects
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aeqz committed Jan 10, 2023
1 parent 20f3d05 commit d9305d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ There are several ways to fix this:
1. How does `xrefcheck` handle redirects?
* The rules from the default configuration are as follows:
* 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
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
Expand Down
6 changes: 3 additions & 3 deletions tests/Test/Xrefcheck/RedirectDefaultSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Xrefcheck.Verify

test_redirectRequests :: TestTree
test_redirectRequests = testGroup "Redirect response defaults"
[ testGroup "Temporary" $ temporaryRedirectTests <$> [302, 303, 307]
[ testGroup "Temporary and 304" $ allowedRedirectTests <$> [302, 303, 304, 307]
, testGroup "Permanent" $ permanentRedirectTests <$> [301, 308]
]
where
Expand All @@ -33,8 +33,8 @@ test_redirectRequests = testGroup "Redirect response defaults"
location :: Maybe Text
location = Just "http://127.0.0.1:5000/other"

temporaryRedirectTests :: Int -> TestTree
temporaryRedirectTests statusCode =
allowedRedirectTests :: Int -> TestTree
allowedRedirectTests statusCode =
redirectTests
(show statusCode <> " passes by default")
(mkStatus statusCode "Temporary redirect")
Expand Down

0 comments on commit d9305d7

Please sign in to comment.