-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
look at the body to determine if it has content or not #149
Conversation
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Codecov Report
@@ Coverage Diff @@
## master #149 +/- ##
==========================================
- Coverage 80.9% 80.59% -0.32%
==========================================
Files 40 40
Lines 2299 2329 +30
==========================================
+ Hits 1860 1877 +17
- Misses 337 347 +10
- Partials 102 105 +3
Continue to review full report at Codecov.
|
if p.underlying.Buffered() > 0 { | ||
return true | ||
} | ||
b, err := p.underlying.Peek(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this return pre-decoded bytes? If so, we may need to be careful about the the fact that an empty entity-body in chunked
transfer-encoding is represented as a single ascii "0" after headers, and before the terminating CRLF.
Something like:
..headers...
transfer-encoding: chunked\r\n
\r\n
0\r\n
If this underlying
was given bytes that already handles the transfer "decoding" then we should be safe here, but I can't tell exactly from the surrounding code just yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Go documentation is slightly comforting, but not specific:
178 // For server requests, the Request Body is always non-nil
179 // but will return EOF immediately when no body is present.
180 // The Server will close the request body. The ServeHTTP
181 // Handler does not need to.
182 Body io.ReadCloser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great: golang/go#11675 (comment) sounds like it handles transfer encodings, or at least it did 4 years ago.
return false | ||
} | ||
|
||
rdr := newPeekingReader(r.Body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my concern below is invalid if r.Body
represents an entity-body after all transfer-encodings have been applied. but if it does not, then I think the peek(1)
will observe ascii "0" (end of chunk marker) and mistakenly assume there is a body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the go stdlib takes care of this part
I have run a test with the patch and I can confirm it has resolved the issue we were seeing. Thank you! |
Add shim design doc.
fixes #148
Signed-off-by: Ivan Porto Carrero ivan@flanders.co.nz