diff options
| author | Damien Neil <dneil@google.com> | 2021-03-12 13:53:11 -0800 |
|---|---|---|
| committer | Damien Neil <dneil@google.com> | 2021-06-04 17:33:24 +0000 |
| commit | 831f9376d8d730b16fb33dfd775618dffe13ce7a (patch) | |
| tree | 284b178840910a1140ff6739b3f1ac31befdede6 /misc/cgo/errors | |
| parent | 3a9d906edcfd0fa574ecd5498f8999b56f1e5fa1 (diff) | |
| download | go-831f9376d8d730b16fb33dfd775618dffe13ce7a.tar.xz | |
net/http: fix ResponseWriter.ReadFrom with short reads
CL 249238 changes ResponseWriter.ReadFrom to probe the source with
a single read of sniffLen bytes before writing the response header.
If the source returns less than sniffLen bytes without reaching
EOF, this can cause Content-Type and Content-Length detection to
fail.
Fix ResponseWrite.ReadFrom to copy a full sniffLen bytes from
the source as a probe.
Drop the explicit call to w.WriteHeader; writing the probe will
trigger a WriteHeader call.
Consistently use io.CopyBuffer; ReadFrom has already acquired a
copy buffer, so it may as well use it.
Fixes #44953.
Change-Id: Ic49305fb827a2bd7da4764b68d64b797b5157dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/301449
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'misc/cgo/errors')
0 files changed, 0 insertions, 0 deletions
