Fix memory reusage bug with auth

Fixes #814
This commit is contained in:
Erik Dubbelboer
2020-05-25 20:26:56 +02:00
parent 24410e58c0
commit 123f6a8cee
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ func TestClientURLAuth(t *testing.T) {
for up, expected := range cases {
req := AcquireRequest()
req.Header.SetMethod(MethodGet)
req.SetRequestURI("http://" + up + "example.com")
req.SetRequestURI("http://" + up + "example.com/foo/bar")
if err := c.Do(req, nil); err != nil {
t.Fatal(err)
}
+4 -4
View File
@@ -284,11 +284,11 @@ func (u *URI) parse(host, uri []byte, isTLS bool) {
host = host[n+1:]
if n := bytes.Index(auth, strColon); n >= 0 {
u.username = auth[:n]
u.password = auth[n+1:]
u.username = append(u.username[:0], auth[:n]...)
u.password = append(u.password[:0], auth[n+1:]...)
} else {
u.username = auth
u.password = auth[:0] // Make sure it's not nil
u.username = append(u.username[:0], auth...)
u.password = u.password[:0]
}
}