MCPcopy Index your code
hub / github.com/containerd/containerd / createGetReq

Method createGetReq

core/remotes/docker/fetcher.go:332–360  ·  view source on GitHub ↗
(ctx context.Context, host RegistryHost, lastHost bool, mediatype string, ps ...string)

Source from the content-addressed store, hash-verified

330}
331
332func (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
362func (r dockerFetcher) FetchByDigest(ctx context.Context, dgst digest.Digest, opts ...remotes.FetchByDigestOpts) (io.ReadCloser, ocispec.Descriptor, error) {
363 var desc ocispec.Descriptor

Callers 1

FetchByDigestMethod · 0.95

Calls 7

requestMethod · 0.80
addNamespaceMethod · 0.80
doWithRetriesMethod · 0.80
sanitizedURLMethod · 0.80
HostnameMethod · 0.65
SetMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected