diff options
| author | Adnan Maolood <[email protected]> | 2021-02-21 09:40:31 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-21 09:41:00 -0500 |
| commit | a4b976c2dc520fc125417863d6c8ee2a84d57572 (patch) | |
| tree | 767f1a749ee761a3a994f8075d3da43c1520f80a | |
| parent | Use StatusHandler in NotFoundHandler implementation (diff) | |
| download | go-gemini-a4b976c2dc520fc125417863d6c8ee2a84d57572.tar.xz go-gemini-a4b976c2dc520fc125417863d6c8ee2a84d57572.zip | |
client: Copy only what is needed from the Request
| -rw-r--r-- | client.go | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -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 - - // Set the host - req.URL.Host = net.JoinHostPort(host, port) + // Copy the URL and update the host + u := new(url.URL) + *u = *req.URL + u.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 |