]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: clarify that MaxBytesReader returns *MaxBytesError
authorDamien Neil <dneil@google.com>
Mon, 11 Jul 2022 16:49:14 +0000 (09:49 -0700)
committerDamien Neil <dneil@google.com>
Tue, 12 Jul 2022 04:04:17 +0000 (04:04 +0000)
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>

src/net/http/request.go

index d091f3c056ab0a4116e1ca444a4801cd09d4be6a..cead91d3d4471c168631bc9a62048584e307597a 100644 (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,