You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
When I using gclient.Client chaining function Cookie, I found an unexpected error.
funcTest_Client_Chain_Cookie(t*testing.T) {
s:=g.Server(guid.S())
s.BindHandler("/cookie", func(r*ghttp.Request) {
r.Response.Write(r.Cookie.Get("test", "def")) // response cookie's value, or `def` if cookie does not exist
})
s.SetDumpRouterMap(false)
s.Start()
defers.Shutdown()
ctx:=context.Background()
time.Sleep(100*time.Millisecond)
gtest.C(t, func(t*gtest.T) {
c:=g.Client()
c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort()))
// client c does not have cookie, return `def`t.Assert(c.GetContent(ctx, "/cookie"), "def")
// chaining function returns client c's copy with cookiecopyWithCookie:=c.Cookie(g.MapStrStr{"test": "1234567890"})
t.Assert(copyWithCookie.GetContent(ctx, "/cookie"), "1234567890")
// client c didn't change, does not have cookie still, should return `def`t.Assert(c.GetContent(ctx, "/cookie"), "def")
})
}
Go version
go version go1.20.4 darwin/amd64
GoFrame version
2.7.4
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
When I using
gclient.Client
chaining functionCookie
, I found an unexpected error.What did you see happen?
But test result like:
What did you expect to see?
I found the
Clone
function ofgclient.Client
:So, if the original client has no header or cookie, then the new client would not allocate header or cookie field.
And, in
New
function, a new client always create withUser-Agent
header, so this problem didn't happened with chaining functionHeader
.Maybe I can fix this problem by submit a pull request like this?
The text was updated successfully, but these errors were encountered: