net/textproto: document enforcement of RFC 9112 for headers

Fixes #68590

Change-Id: Ie7cf1fe8379182f86317d5ebb7f45a404ecd70e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/601555
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Sean Liao 2024-07-27 09:15:31 +01:00 committed by Gopher Robot
parent 2ce1fb4220
commit 3b9d10cce7
2 changed files with 5 additions and 2 deletions

View File

@ -642,8 +642,8 @@ func (r *Reader) upcomingHeaderKeys() (n int) {
// the rest are converted to lowercase. For example, the // the rest are converted to lowercase. For example, the
// canonical key for "accept-encoding" is "Accept-Encoding". // canonical key for "accept-encoding" is "Accept-Encoding".
// MIME header keys are assumed to be ASCII only. // MIME header keys are assumed to be ASCII only.
// If s contains a space or invalid header field bytes, it is // If s contains a space or invalid header field bytes as
// returned without modifications. // defined by RFC 9112, it is returned without modifications.
func CanonicalMIMEHeaderKey(s string) string { func CanonicalMIMEHeaderKey(s string) string {
// Quick check for canonical encoding. // Quick check for canonical encoding.
upper := true upper := true

View File

@ -5,6 +5,9 @@
// Package textproto implements generic support for text-based request/response // Package textproto implements generic support for text-based request/response
// protocols in the style of HTTP, NNTP, and SMTP. // protocols in the style of HTTP, NNTP, and SMTP.
// //
// This package enforces the HTTP/1.1 character set defined by
// RFC 9112 for header keys and values.
//
// The package provides: // The package provides:
// //
// [Error], which represents a numeric error response from // [Error], which represents a numeric error response from