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

Commit

Permalink
Clone the HTTP request for the HEAD. (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmoor authored May 30, 2024
1 parent 3abd88f commit 2ff9aee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/apk/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func (e *etagCache) get(t *cacheTransport, request *http.Request, cacheFile stri
// Do all the expensive things inside the once.
once, _ := e.etags.LoadOrStore(url, &sync.Once{})
once.(*sync.Once).Do(func() {
resp, rerr := t.wrapped.Head(url)
req := request.Clone(request.Context())
req.Method = http.MethodHead
resp, rerr := t.wrapped.Do(req)
if resp != nil {
// We don't expect any body from a HEAD so just always close it to appease the linter.
resp.Body.Close()
Expand Down

0 comments on commit 2ff9aee

Please sign in to comment.