Skip to content

Add HEAD request support - #12

Merged
RCasatta merged 1 commit into
masterfrom
compression-and-head
Jul 24, 2026
Merged

Add HEAD request support#12
RCasatta merged 1 commit into
masterfrom
compression-and-head

Conversation

@DeviaVir

@DeviaVir DeviaVir commented Jul 23, 2026

Copy link
Copy Markdown

curl -I .../v1/server_recipient used to return 404 because the router only matched GET literally. HEAD requests are now routed through the GET handlers and the body is stripped just before the response is written, so status, headers, and Content-Length are exactly what the corresponding GET would return (RFC 9110). Access-Control-Allow-Methods now 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

  • Integration coverage in 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, and cargo fmt --check pass locally.

Docs: docs/API.md gained a "Response Behavior" section describing HEAD semantics.

@DeviaVir DeviaVir self-assigned this Jul 23, 2026
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
DeviaVir force-pushed the compression-and-head branch from 2670e47 to f70eda9 Compare July 23, 2026 18:46
@DeviaVir DeviaVir changed the title Add gzip compression for JSON responses and HEAD request support Add HEAD request support Jul 23, 2026
@DeviaVir
DeviaVir requested a review from RCasatta July 23, 2026 19:20
@RCasatta
RCasatta merged commit f70eda9 into master Jul 24, 2026
3 checks passed
@RCasatta

Copy link
Copy Markdown

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

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