aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-05-22 15:03:13 -0400
committerGopher Robot <gobot@golang.org>2024-05-23 01:16:53 +0000
commit05cbbf985fed823a174bf95cc78a7d44f948fdab (patch)
treeffdb52c7ce57360323e22a68e20f45d10771a004 /src/net/http
parent1d3d6ae725697c5b224b26cb3aa1325ac37f72d7 (diff)
downloadgo-05cbbf985fed823a174bf95cc78a7d44f948fdab.tar.xz
all: document legacy //go:linkname for modules with ≥500 dependents
For #67401. Change-Id: I7dd28c3b01a1a647f84929d15412aa43ab0089ee Reviewed-on: https://go-review.googlesource.com/c/go/+/587575 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/badlinkname.go2
-rw-r--r--src/net/http/request.go20
2 files changed, 20 insertions, 2 deletions
diff --git a/src/net/http/badlinkname.go b/src/net/http/badlinkname.go
index 93408ecd55..98726b1071 100644
--- a/src/net/http/badlinkname.go
+++ b/src/net/http/badlinkname.go
@@ -20,10 +20,8 @@ import _ "unsafe"
//go:linkname cloneURLValues
//go:linkname newBufioReader
//go:linkname newBufioWriterSize
-//go:linkname parseBasicAuth
//go:linkname putBufioReader
//go:linkname putBufioWriter
-//go:linkname readRequest
// The compiler doesn't allow linknames on methods, for good reasons.
// We use this trick to push linknames of the methods.
diff --git a/src/net/http/request.go b/src/net/http/request.go
index f208b95c46..ecb48a4364 100644
--- a/src/net/http/request.go
+++ b/src/net/http/request.go
@@ -25,6 +25,7 @@ import (
"strconv"
"strings"
"sync"
+ _ "unsafe" // for linkname
"golang.org/x/net/http/httpguts"
"golang.org/x/net/idna"
@@ -986,6 +987,16 @@ func (r *Request) BasicAuth() (username, password string, ok bool) {
// parseBasicAuth parses an HTTP Basic Authentication string.
// "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" returns ("Aladdin", "open sesame", true).
+//
+// parseBasicAuth should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/sagernet/sing
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname parseBasicAuth
func parseBasicAuth(auth string) (username, password string, ok bool) {
const prefix = "Basic "
// Case insensitive prefix match. See Issue 22736.
@@ -1061,6 +1072,15 @@ func ReadRequest(b *bufio.Reader) (*Request, error) {
return req, err
}
+// readRequest should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/sagernet/sing
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname readRequest
func readRequest(b *bufio.Reader) (req *Request, err error) {
tp := newTextprotoReader(b)
defer putTextprotoReader(tp)