diff --git a/pool.go b/pool.go index a065d4d..08f0183 100644 --- a/pool.go +++ b/pool.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "net/http" - "net/url" "os" "strings" "sync" @@ -223,17 +222,12 @@ func (p *pool) doFetch(ctx context.Context, from string, c cid.Cid) (b blocks.Bl UserAgent: respReq.UserAgent(), } }() - u, err := url.Parse(fmt.Sprintf(tmpl, from, c)) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf(tmpl, from, c), nil) if err != nil { return nil, err } - req := http.Request{ - Method: http.MethodGet, - URL: u, - Header: http.Header{ - "Accept": []string{"application/vnd.ipld.raw"}, - }, - } + + req.Header.Add("Accept", "application/vnd.ipld.raw") if p.config.ExtraHeaders != nil { for k, vs := range *p.config.ExtraHeaders { for _, v := range vs { @@ -242,7 +236,7 @@ func (p *pool) doFetch(ctx context.Context, from string, c cid.Cid) (b blocks.Bl } } - resp, err := p.config.Client.Do(&req) + resp, err := p.config.Client.Do(req) if err != nil { return nil, err }