Skip to content

Support HTTP request method fallback#2218

Merged
mre merged 5 commits into
masterfrom
feature/method-fallback
May 31, 2026
Merged

Support HTTP request method fallback#2218
mre merged 5 commits into
masterfrom
feature/method-fallback

Conversation

@mre

@mre mre commented May 30, 2026

Copy link
Copy Markdown
Member

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

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
Comment thread lychee-lib/src/types/methods.rs
Comment thread examples/builder/builder.rs Outdated
Comment thread lychee-lib/src/ratelimit/host/host.rs

@katrinafyi katrinafyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy in principle, though I haven't dived into actually running it. I'm also okay with the Methods abstraction.

Comment thread lychee-bin/src/config/mod.rs
Comment thread examples/builder/builder.rs Outdated

@thomas-zahner thomas-zahner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I didn't spot any big issues. Just two small details.

Comment thread lychee-bin/tests/cli.rs Outdated
Comment thread lychee-lib/src/checker/website.rs Outdated
Comment thread lychee-lib/src/types/methods.rs
mre added 2 commits May 31, 2026 23:01
- methods -> method
- update commments
- clean up cli test
@mre mre force-pushed the feature/method-fallback branch from a5a8a5b to eb81c41 Compare May 31, 2026 21:12
@mre mre merged commit 29085ca into master May 31, 2026
8 checks passed
@mre mre deleted the feature/method-fallback branch May 31, 2026 21:18
@mre mre mentioned this pull request May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support HTTP request method fallback

3 participants