aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
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)