1
0
mirror of https://github.com/golang/go synced 2024-09-29 03:24:29 -06:00

net/http: clarify that MaxBytesReader returns *MaxBytesError

A MaxBytesReader returns a *MaxBytesError when reading beyond
its limit, not a MaxBytesError.

Fixes #53764.

Change-Id: Icac3aeac96fd8b172f951241f8f111cda633752c
Reviewed-on: https://go-review.googlesource.com/c/go/+/416914
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Damien Neil 2022-07-11 09:49:14 -07:00
parent 126c22a098
commit d3d7998756

View File

@ -1126,8 +1126,8 @@ func readRequest(b *bufio.Reader) (req *Request, err error) {
// MaxBytesReader is similar to io.LimitReader but is intended for
// limiting the size of incoming request bodies. In contrast to
// io.LimitReader, MaxBytesReader's result is a ReadCloser, returns a
// MaxBytesError for a Read beyond the limit, and closes the
// underlying reader when its Close method is called.
// non-nil error of type *MaxBytesError for a Read beyond the limit,
// and closes the underlying reader when its Close method is called.
//
// MaxBytesReader prevents clients from accidentally or maliciously
// sending a large request and wasting server resources. If possible,