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

Function newBodyReader

docker/body_reader.go:46–65  ·  view source on GitHub ↗

newBodyReader creates a bodyReader for request path in c. firstBody is an already correctly opened body for the blob, returning the full blob from the start. If reading from firstBody fails, bodyReader may heuristically decide to resume.

(ctx context.Context, c *dockerClient, path string, firstBody io.ReadCloser)

Source from the content-addressed store, hash-verified

44// firstBody is an already correctly opened body for the blob, returning the full blob from the start.
45// If reading from firstBody fails, bodyReader may heuristically decide to resume.
46func newBodyReader(ctx context.Context, c *dockerClient, path string, firstBody io.ReadCloser) (io.ReadCloser, error) {
47 logURL, err := c.resolveRequestURL(path)
48 if err != nil {
49 return nil, err
50 }
51 res := &bodyReader{
52 ctx: ctx,
53 c: c,
54 path: path,
55 logURL: logURL,
56 firstConnectionTime: time.Now(),
57
58 body: firstBody,
59 lastRetryOffset: -1,
60 lastRetryTime: time.Time{},
61 offset: 0,
62 lastSuccessTime: time.Time{},
63 }
64 return res, nil
65}
66
67// parseDecimalInString ensures that s[start:] starts with a non-negative decimal number, and returns that number and the offset after the number.
68func parseDecimalInString(s string, start int) (int64, int, error) {

Callers 1

getBlobMethod · 0.85

Calls 1

resolveRequestURLMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…