The method http.ReadRequest
takes a bufio.Reader
instead of an io.Reader
. What is the reason behind this?
It will use buffered reader anyway. But it will not automatically wrap your io.Reader
into buffer because of bufio.Reader
nature - it can grab more data from underlying io.Reader
that algorithm actually need. And, since underlying io.Reader
cannot push back that exceed data, it will remain in that buffer. In case of autowrap that buffer would be lost after request was read and your io.Reader
become corrupted. Thus, it ask you to explicitly wrap your reader to prevent data loss.