client: Copy only what is needed from the Request
This commit is contained in:
parent
b784442b6d
commit
a4b976c2dc
17
client.go
17
client.go
@ -74,15 +74,16 @@ func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) {
|
|||||||
if host != punycode {
|
if host != punycode {
|
||||||
host = punycode
|
host = punycode
|
||||||
|
|
||||||
// Make a copy of the request
|
// Copy the URL and update the host
|
||||||
r2 := new(Request)
|
u := new(url.URL)
|
||||||
*r2 = *req
|
*u = *req.URL
|
||||||
r2.URL = new(url.URL)
|
u.Host = net.JoinHostPort(host, port)
|
||||||
*r2.URL = *req.URL
|
|
||||||
req = r2
|
|
||||||
|
|
||||||
// Set the host
|
// Use the new URL in the request so that the server gets
|
||||||
req.URL.Host = net.JoinHostPort(host, port)
|
// the punycoded hostname
|
||||||
|
req = &Request{
|
||||||
|
URL: u,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use request host if provided
|
// Use request host if provided
|
||||||
|
Loading…
Reference in New Issue
Block a user