http: don't wait for bodies of empty responses #934
Merged
+21
−6
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.
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:
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%continueand%canceleffects are noops.Additionaly, response body is set to 0 for all informational responses (1xx), 204, 205 (Reset Content) and 304 (Not Modified).