mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-16 16:17:38 +03:00
Properly copy query arguments in URI.CopyTo
This commit is contained in:
@@ -62,7 +62,8 @@ func (u *URI) CopyTo(dst *URI) {
|
||||
dst.hash = append(dst.hash[:0], u.hash...)
|
||||
dst.host = append(dst.host[:0], u.host...)
|
||||
|
||||
dst.parsedQueryArgs = false
|
||||
u.queryArgs.CopyTo(&dst.queryArgs)
|
||||
dst.parsedQueryArgs = u.parsedQueryArgs
|
||||
|
||||
// fullURI and requestURI shouldn't be copied, since they are created
|
||||
// from scratch on each FullURI() and RequestURI() call.
|
||||
|
||||
+14
@@ -7,6 +7,20 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestURICopyToQueryArgs(t *testing.T) {
|
||||
var u URI
|
||||
a := u.QueryArgs()
|
||||
a.Set("foo", "bar")
|
||||
|
||||
var u1 URI
|
||||
u.CopyTo(&u1)
|
||||
a1 := u1.QueryArgs()
|
||||
|
||||
if string(a1.Peek("foo")) != "bar" {
|
||||
t.Fatalf("unexpected query args value %q. Expecting %q", a1.Peek("foo"), "bar")
|
||||
}
|
||||
}
|
||||
|
||||
func TestURIAcquireReleaseSequential(t *testing.T) {
|
||||
testURIAcquireRelease(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user