Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

fix: request honours upstream context #18

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
"sync"
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down