mirror of
https://git.sr.ht/~adnano/go-gemini
synced 2024-09-19 18:53:43 +02:00
client: Copy only what is needed from the Request
This commit is contained in:
parent
070c258c8d
commit
b90b5bf2dc
17
client.go
17
client.go
@ -74,15 +74,16 @@ func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) {
|
||||
if host != punycode {
|
||||
host = punycode
|
||||
|
||||
// Make a copy of the request
|
||||
r2 := new(Request)
|
||||
*r2 = *req
|
||||
r2.URL = new(url.URL)
|
||||
*r2.URL = *req.URL
|
||||
req = r2
|
||||
// Copy the URL and update the host
|
||||
u := new(url.URL)
|
||||
*u = *req.URL
|
||||
u.Host = net.JoinHostPort(host, port)
|
||||
|
||||
// Set the host
|
||||
req.URL.Host = net.JoinHostPort(host, port)
|
||||
// Use the new URL in the request so that the server gets
|
||||
// the punycoded hostname
|
||||
req = &Request{
|
||||
URL: u,
|
||||
}
|
||||
}
|
||||
|
||||
// Use request host if provided
|
||||
|
Loading…
Reference in New Issue
Block a user