Add HEAD request support - #12
Merged
Merged
Conversation
Route HEAD requests through the GET handlers and strip the body before returning, so status, headers and Content-Length match the corresponding GET response (RFC 9110). Previously the router matched GET literally and HEAD returned 404. Access-Control-Allow-Methods now advertises HEAD as well. Documented in docs/API.md and covered by an integration test asserting HEAD/GET parity (status, headers, Content-Length, empty body).
DeviaVir
force-pushed
the
compression-and-head
branch
from
July 23, 2026 18:46
2670e47 to
f70eda9
Compare
|
Looks good, thanks. We may decide in the future to skip body computation entirely for HEAD, but it seems an almost worthless edge-case optimization |
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.
curl -I .../v1/server_recipientused to return 404 because the router only matchedGETliterally. HEAD requests are now routed through the GET handlers and the body is stripped just before the response is written, so status, headers, andContent-Lengthare exactly what the corresponding GET would return (RFC 9110).Access-Control-Allow-Methodsnow advertises HEAD as well.This PR originally also added in-app gzip compression; that was dropped after review feedback: compression stays at the reverse-proxy/LB layer, HEAD support is kept native so waterfalls behaves correctly behind load balancers that pass methods through unchanged. This should be suitable for upstreaming.
Tests
do_test(head_matches_get): HEAD returns the same status/headers as GET (incl.Content-Length) with an empty body.cargo test --lib(90 tests),integration_memory_elements,cargo clippy -- -D warnings, andcargo fmt --checkpass locally.Docs:
docs/API.mdgained a "Response Behavior" section describing HEAD semantics.