Skip to content

test: cover cut-off request bodies and http/2 clients - #18

Merged
jamiehdev merged 1 commit into
mainfrom
test/body-failure-and-http2
Sep 27, 2026
Merged

jamiehdev merged 1 commit into
mainfrom
test/body-failure-and-http2

Conversation

@jamiehdev

Copy link
Copy Markdown
Owner

This adds integration tests for two untested paths: a request body that fails partway through, and HTTP/2 clients on the TLS listener. The proxy code does not change.

Changes

  • tests/integration/body_failure.rs puts a raw TCP origin behind a real proxy socket. The client stops a Content-Length body or a chunked body partway, or sends a malformed chunk size. The tests assert that the origin never gets a whole request. For a half-close, the client gets a 502. For bad chunk framing, actix closes the connection with no response. After each case, /health returns 200.
  • tests/integration/http2.rs uses a hyper client that offers only h2 through ALPN and checks Version::HTTP_2 on every response. It covers a proxied GET, a 200 KB POST body, a cache MISS then HIT, and X-Forwarded-Proto: https with X-Forwarded-Host taken from :authority.
  • A further HTTP/2 test sends origin responses that hold Connection, Keep-Alive, TE, Upgrade and a field that Connection names. The test requests the response fresh and from the cache. The h2 crate refuses to send TE: gzip, and actix removes only some of these fields itself.

Verification

  • A change to pump_request_body that drops the payload error makes the chunked half-close test fail, because the origin then gets a 0\r\n\r\n last chunk.
  • The Content-Length test still passes under that change, because hyper also aborts a body that ends before its declared length. The malformed-chunk test also still passes, because actix drops the handler, which cancels the origin request.
  • Removing te from the proxy hop-by-hop list resets the h2 stream. Ignoring the URI authority in ClientInfo fails the X-Forwarded-Host assertion.
  • Five full local runs and twenty runs of the new tests passed.

@jamiehdev

Copy link
Copy Markdown
Owner Author

@codex review, and also report simplification opportunities in the changed code as P1: logic that duplicates an existing helper, dead code, needless indirection or abstraction, and conditionals or loops with a shorter equivalent. Flag one only when the shorter version behaves the same, and show the replacement code. Do not flag style, naming or formatting.

@jamiehdev
jamiehdev merged commit 7462a42 into main Sep 27, 2026
2 checks passed
@jamiehdev
jamiehdev deleted the test/body-failure-and-http2 branch September 27, 2026 16:09
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.

1 participant