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 working on an HTTP endpoint that requires a POST body, but found it difficult to understand how to hold the httpx package in a way that allowed me to obtain the body contents as the request type does not expose the content length and does not allow a read to
io.EOF
of the net conn.If I attempt to read the contents of
buf
to completion after the headers have been read, I get a "curl: (52) Empty reply from server" from the test client and seelevel=ERROR msg=Stack.RecvEth err="dropped packet"
andpoll error: dropped packet
in the server logs.This appears to be due to the request waiting on the response because the buffer believes the conn still has data; I see this:
level=ERROR msg="read body" err="i/o timeout"
. It seems I need to know the content length to be able to know when to stop.To get around this I tried using the standard library's net/http package in the servers code and it works. This change is the equivalent change for the http-server example.
Note that while it works (and in the server that I am writing that prompted this does not cause any
poll error: dropped packet
error to be emitted, I do see that happening in the server example. I have been unable to see how the two programs differ in a way that would explain this. The error is coming from(*TCPListener).recv
.