(resp *http.Response)
| 1016 | } |
| 1017 | |
| 1018 | func 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. |
no outgoing calls
searching dependent graphs…