Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dozreg-toplud
Copy link
Contributor

@dozreg-toplud dozreg-toplud commented Dec 27, 2025

I was seeing 502 Bad Gateway in some of responses to polling requests in the web interface of a Gall agent. Caddy logs showed an error:

transport connection broken: malformed HTTP version "nullHTTP/1.1"

Notably, I was sending "null" body with 204 No Content response, which must not have a body. Changing response to "true" changed the HTTP version to "trueHTTP/1.1"

After playing around in http.c I came to a conclusion that h2o is probably not waiting for the rest of the response, since it assumes that it won't have a body according to the HTTP spec.

So what probably happens is, Eyre sends the rest of 204 response body, while h2o already moved on. Body of the response is left in some buffer which gets concatenated with the next response, corrupting it.

This PR adds another HTTP request state, u3_rsat_sown, which guarantees that the response was already sent. Following %continue and %cancel effects are noops.

Additionaly, response body is set to 0 for all informational responses (1xx), 204, 205 (Reset Content) and 304 (Not Modified).

@dozreg-toplud dozreg-toplud requested a review from a team as a code owner December 27, 2025 09:35
@dozreg-toplud dozreg-toplud requested a review from joemfb December 27, 2025 09:35
@dozreg-toplud
Copy link
Contributor Author

Tried running my planet with the latest fix, no 502s encountered

@dozreg-toplud
Copy link
Contributor Author

this is the culprit I believe, found by global search for '204' in h20 repo in zig cache and setting breakpoints in GDB: https://github.com/pkova/h2o/blob/3bbfe369a5c31d38cc1717e5281ca6af89ecf787/lib/handler/chunked.c#L81

@dozreg-toplud
Copy link
Contributor Author

in addition to the empty responses included above, any response to a "HEAD" request must not have a body either, both according to the HTTP spec and to the on_setup_ostream logic

@pkova pkova merged commit 75c5e9b into develop Jan 12, 2026
2 checks passed
@pkova pkova deleted the dozreg/http-no-body branch January 12, 2026 16:12
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.

3 participants