(ctx context.Context, host RegistryHost, lastHost bool, mediatype string, ps ...string)
| 330 | } |
| 331 | |
| 332 | func (r dockerFetcher) createGetReq(ctx context.Context, host RegistryHost, lastHost bool, mediatype string, ps ...string) (*request, int64, error) { |
| 333 | headReq := r.request(host, http.MethodHead, ps...) |
| 334 | if err := headReq.addNamespace(r.refspec.Hostname()); err != nil { |
| 335 | return nil, 0, err |
| 336 | } |
| 337 | |
| 338 | if mediatype == "" { |
| 339 | headReq.header.Set("Accept", "*/*") |
| 340 | } else { |
| 341 | headReq.header.Set("Accept", strings.Join([]string{mediatype, `*/*`}, ", ")) |
| 342 | } |
| 343 | |
| 344 | headResp, err := headReq.doWithRetries(ctx, lastHost) |
| 345 | if err != nil { |
| 346 | return nil, 0, err |
| 347 | } |
| 348 | if headResp.Body != nil { |
| 349 | headResp.Body.Close() |
| 350 | } |
| 351 | if headResp.StatusCode > 299 { |
| 352 | return nil, 0, fmt.Errorf("unexpected HEAD status code %v: %s", headReq.sanitizedURL(), headResp.Status) |
| 353 | } |
| 354 | |
| 355 | getReq := r.request(host, http.MethodGet, ps...) |
| 356 | if err := getReq.addNamespace(r.refspec.Hostname()); err != nil { |
| 357 | return nil, 0, err |
| 358 | } |
| 359 | return getReq, headResp.ContentLength, nil |
| 360 | } |
| 361 | |
| 362 | func (r dockerFetcher) FetchByDigest(ctx context.Context, dgst digest.Digest, opts ...remotes.FetchByDigestOpts) (io.ReadCloser, ocispec.Descriptor, error) { |
| 363 | var desc ocispec.Descriptor |
no test coverage detected