Support HTTP request method fallback#2218
Merged
Merged
Conversation
Previously, lychee only supported a single request method for all servers: HEAD. This caused trouble, because some servers do not accept HEAD requests. However, using HEAD is a sane default, as it is more efficent/lightweight than GET requests. Allow the configuration key method to be a list ["head", "get"] instead of a string, where Lychee's checking algorithm falls back to the subsequent HTTP method in the list if the former gives an error response. This will always retry the request until the list of request methods gets exhausted. The only exception are timeouts, in which case the iteration stops and the status gets returned immediately. Fixes #1327
mre
commented
May 30, 2026
mre
commented
May 30, 2026
mre
commented
May 30, 2026
katrinafyi
reviewed
May 31, 2026
katrinafyi
left a comment
Member
There was a problem hiding this comment.
Happy in principle, though I haven't dived into actually running it. I'm also okay with the Methods abstraction.
thomas-zahner
approved these changes
May 31, 2026
thomas-zahner
left a comment
Member
There was a problem hiding this comment.
Nice, I didn't spot any big issues. Just two small details.
- methods -> method - update commments - clean up cli test
a5a8a5b to
eb81c41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, lychee only supported a single request method for all servers: HEAD.
This caused trouble, because some servers do not accept HEAD requests. However, using HEAD is a sane default, as it is more efficient/lightweight than GET requests.
Allow the configuration key method to be a list ["head", "get"] instead of a string, where Lychee's checking algorithm falls back to the subsequent HTTP method in the list if the former gives an error response.
This will always retry the request until the list of request methods gets exhausted. The only exception are timeouts, in which case the iteration stops and the status gets returned immediately.
Fixes #1327
@sanmai-NL fyi