Skip to content

feat: convenience function for HEAD requests#8

Merged
jjhafer merged 1 commit into
silvermine:masterfrom
jjhafer:add_head_convenience_method
Apr 30, 2026
Merged

feat: convenience function for HEAD requests#8
jjhafer merged 1 commit into
silvermine:masterfrom
jjhafer:add_head_convenience_method

Conversation

@jjhafer
Copy link
Copy Markdown
Contributor

@jjhafer jjhafer commented Apr 30, 2026

Adds a convenient Rust function for making HEAD requests. This allows Rust callers to avoid using a Reqwest type needed to call the general request function.

@jjhafer jjhafer requested a review from velocitysystems April 30, 2026 15:44
Comment thread src/client.rs
///
/// Returns a [`RequestBuilder`](crate::request::RequestBuilder) that can
/// be customized with headers, timeout, and retry settings before sending.
pub fn head(&self, url: impl Into<String>) -> crate::request::RequestBuilder<'_> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This calls read_body_with_limit which rejects responses whose advertised Content-Length exceeds max_response_body_size — but for HEAD that's the intended body size, not actual bytes received.

So a head() call against any resource larger than 10 MiB (with the default config) will fail with ResponseTooLarge. This is a pre-existing behavior not introduced with this PR; but worth calling out since it will affect our intended use case for this API method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@velocitysystems Excellent catch! Fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great!

Adds a convenient Rust function for making HEAD requests. This
allows Rust callers to avoid using a Reqwest type needed to call
the general `request` function.
@jjhafer jjhafer force-pushed the add_head_convenience_method branch from 2b7cb9c to 33f4d38 Compare April 30, 2026 18:40
@jjhafer jjhafer requested a review from velocitysystems April 30, 2026 18:41
@jjhafer jjhafer merged commit 5fefa57 into silvermine:master Apr 30, 2026
1 check passed
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.

2 participants