Copy to the req.Header.userAgent from the defaultUserAgent (#796)

This avoids the req.Header.userAgent sharing an underlying array with the
global defaultUserAgent

This should fix the #795
This commit is contained in:
Julian Junxiang Zhou
2020-04-30 19:06:48 +08:00
committed by GitHub
parent 32940977fb
commit dc6b9db734
+1 -1
View File
@@ -1321,7 +1321,7 @@ func (c *HostClient) doNonNilReqResp(req *Request, resp *Response) (bool, error)
userAgentOld := req.Header.UserAgent()
if len(userAgentOld) == 0 {
req.Header.userAgent = c.getClientName()
req.Header.userAgent = append(req.Header.userAgent[:0], c.getClientName()...)
}
bw := c.acquireWriter(conn)
err = req.Write(bw)