mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-19 16:47:16 +03:00
Don't unwrap io.LimitedReader
This is not needed anymore to trigger sendfile. The Go wrapper around sendfile already does this: https://github.com/golang/go/blob/9d46ee5ac4acd6602692f70c5149a3f6db058558/src/net/sendfile_linux.go#L23-L33
This commit is contained in:
@@ -1856,19 +1856,8 @@ func writeBodyFixedSize(w *bufio.Writer, r io.Reader, size int64) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Unwrap a single limited reader for triggering sendfile path
|
||||
// in net.TCPConn.ReadFrom.
|
||||
lr, ok := r.(*io.LimitedReader)
|
||||
if ok {
|
||||
r = lr.R
|
||||
}
|
||||
|
||||
n, err := copyZeroAlloc(w, r)
|
||||
|
||||
if ok {
|
||||
lr.N -= n
|
||||
}
|
||||
|
||||
if n != size && err == nil {
|
||||
err = fmt.Errorf("copied %d bytes from body stream instead of %d bytes", n, size)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user