Skip to content

Fix bug with Raw Server causing AHC tests to fail on Linux#128

Open
xbhatnag wants to merge 4 commits intomainfrom
fix-raw-server
Open

Fix bug with Raw Server causing AHC tests to fail on Linux#128
xbhatnag wants to merge 4 commits intomainfrom
fix-raw-server

Conversation

@xbhatnag
Copy link
Collaborator

@xbhatnag xbhatnag commented Mar 9, 2026

Motivation

The Raw Server handler would return every time it received a non-head portion of the request. Unfortunately, every request has a .end portion in addition to the .head portion, meaning that the server would be tearing down the connection after one response despite not including Connection: close in the headers, which confuses the client trying to reuse the connection.

This caused AHC tests in Linux to flakily fail, as observed in #127

Modifications

To fix this, the raw server closes the connection correctly, by adding a Connection: close header to all responses. The server now reads only one set of request headers per connection, writes a response and then closes that connection. Connection re-use is not permitted.

Result

The AHC tests on Linux are not flaky anymore. Tested on docker container running 204 + 304 tests back to back 100+ times.

Test Plan

N/A. This fixes a test.

The Raw Server handler would `return` every time it received a non-head portion of the request. Unfortunately, every request has a `.end` portion in addition to the `.head` portion, meaning that the server would be tearing down the connection after one response despite not including `Connection: close`. To fix this, allow the connection to handle multiple requests by making this a `continue` instead of a `return`.
Copy link
Member

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

cc @gjcairo

fabianfett and others added 3 commits March 11, 2026 10:01
Connection re-use doesn't work correctly for cases where the server is expected to write incomplete un-chunked bodies. Connection re-use would mean that neither the server nor the client close the connection and both are waiting for more data. This causes indefinite hangs. The raw server now receives the headers from a request, writes the response and closes the connection immediately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants