clbanning/mxj

issue with reading req.Body / res.Body directly

Closed this issue · 2 comments

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

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

v2.5.7