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)
| 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. |
| 46 | func 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. |
| 68 | func parseDecimalInString(s string, start int) (int64, int, error) { |
no test coverage detected
searching dependent graphs…