MCPcopy Create free account
hub / github.com/containers/image / getBlobSize

Function getBlobSize

docker/docker_client.go:1018–1032  ·  view source on GitHub ↗
(resp *http.Response)

Source from the content-addressed store, hash-verified

1016}
1017
1018func getBlobSize(resp *http.Response) (int64, error) {
1019 hdrs := resp.Header.Values("Content-Length")
1020 if len(hdrs) == 0 {
1021 return -1, errors.New(`Missing "Content-Length" header in response`)
1022 }
1023 hdr := hdrs[0] // Equivalent to resp.Header.Get(…)
1024 size, err := strconv.ParseInt(hdr, 10, 64)
1025 if err != nil { // Go’s response reader should already reject such values.
1026 return -1, err
1027 }
1028 if size < 0 { // '-' is not a valid character in Content-Length, so negative values are invalid. Go’s response reader should already reject such values.
1029 return -1, fmt.Errorf(`Invalid negative "Content-Length" %q`, hdr)
1030 }
1031 return size, nil
1032}
1033
1034// getBlob returns a stream for the specified blob in ref, and the blob’s size (or -1 if unknown).
1035// The Digest field in BlobInfo is guaranteed to be provided, Size may be -1 and MediaType may be optionally provided.

Callers 4

getExternalBlobMethod · 0.70
getBlobMethod · 0.70
TestGetBlobSizeFunction · 0.70
blobExistsMethod · 0.70

Calls

no outgoing calls

Tested by 1

TestGetBlobSizeFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…