diff options
| author | kovan <xaum.io@gmail.com> | 2026-02-27 23:13:56 +0100 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-11 16:41:01 -0700 |
| commit | 3fc4af70d04682ab42744e4ce78f95025688996d (patch) | |
| tree | 38357dc33cef69bf2be99c3221bdd06406b45aca /src/net/http | |
| parent | c43088c7a6b58861078eb96617c7fc12764dbf76 (diff) | |
| download | go-3fc4af70d04682ab42744e4ce78f95025688996d.tar.xz | |
net/http: document which headers Request.Write handles specially
Document that Header values for Host, Content-Length,
Transfer-Encoding, and Trailer are not used by Write, as these
are derived from other Request fields. Also document that
User-Agent defaults to "Go-http-client/1.1" if not set in Header.
Fixes #68635
Change-Id: Ie182777ae094657cf3971fed989af1bd5e875d9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/741442
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/net/http')
| -rw-r--r-- | src/net/http/request.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/net/http/request.go b/src/net/http/request.go index f49bbeee16..96fb712b81 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -558,6 +558,11 @@ const defaultUserAgent = "Go-http-client/1.1" // If Body is present, Content-Length is <= 0 and [Request.TransferEncoding] // hasn't been set to "identity", Write adds "Transfer-Encoding: // chunked" to the header. Body is closed after it is sent. +// +// Header values for Host, Content-Length, Transfer-Encoding, +// and Trailer are not used; these are derived from other Request fields. +// If the Header does not contain a User-Agent value, Write uses +// "Go-http-client/1.1". func (r *Request) Write(w io.Writer) error { return r.write(w, false, nil, nil) } |
