Only process Connection: close
header if full request was read (fixes #194)
#195
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.
The presence of a
Connection: close
header sets a flag on the request,which we process by no longer running the HTTP parser as soon as it
returns from parsing a chunk. Since HTTP 100 uploads require at least 2
reads, we need to handle the
Connection: close
only if we've reachedthe end of the request. This change sets a flag in
on_message_complete
,which we use in combination with the header to stop reading.
Also adding a test to reproduce this issue and including it in CI job.
@nicolasff I tried to find an existing flag but didn't find anything already set in
http_client_on_message_complete
that I could use. There'sc->keep_alive = 0
just above the flag I set, but it's 0 by default due to thecalloc
so I don't think it's a reliable indicator that the request has been fully parsed. I was also thinking there might be something inside the parser object itself but I didn't really want to rely on its internals (what if it changes later?). But if you have a better idea it might avoid this 1-byte increase, even though this is very small and might actually not make any difference due to alignment.w