Skip to content
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

issue with reading req.Body / res.Body directly #98

Closed
brenol opened this issue Jun 28, 2022 · 2 comments
Closed

issue with reading req.Body / res.Body directly #98

brenol opened this issue Jun 28, 2022 · 2 comments

Comments

@brenol
Copy link

brenol commented Jun 28, 2022

Hello!

First, thank you for such a great project!

I found a small issue when reading req.Body & res.Body, that was already reported at #38. I looked for the commit that changed it back and it's this one: dc2e2f9

Reading through net/http code I see that the only difference is that it uses io.NopCloser in NewRequest, which is what causes the problem mentioned in #38.

After further investigation, I noticed something: io.NopCloser does not implement ReadByte, which make we fallback to the implementation that is found here in mxj.

I found this issue because I had to make some cleanup to a http.Response.Body and wrapped the returned reader (which probably is a *bufio.Reader) with my custom one, causing the issue mentioned in #38.

As the change made in #38 was rolled back, I'm not sure which is the best fix to the current byteReader implementation though, which is why I am only opening a issue and not a PR.

Again, thank you for the great project!

Sample code reproducing the mentioned issue: https://go.dev/play/p/ffJvzhYD1h1

@clbanning
Copy link
Owner

Thanks. I'm traveling and will get to this in a week or so.

clbanning added a commit that referenced this issue Aug 2, 2022
Return EOF no nil on end of file in ReadByte.
@clbanning
Copy link
Owner

v2.5.7

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

No branches or pull requests

2 participants