Make it possible to inspect an initial response and pass it to
ResumableRequestReader. This makes it possible to inspect an initial
response and passing it to ResumableRequestReader to avoid making an
extra request.
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -24,6 +24,10 @@ func ResumableRequestReader(c *http.Client, r *http.Request, maxfail uint32, tot |
| 24 | 24 |
return &resumableRequestReader{client: c, request: r, maxFailures: maxfail, totalSize: totalsize}
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
+func ResumableRequestReaderWithInitialResponse(c *http.Client, r *http.Request, maxfail uint32, totalsize int64, initialResponse *http.Response) io.ReadCloser {
|
|
| 28 |
+ return &resumableRequestReader{client: c, request: r, maxFailures: maxfail, totalSize: totalsize, currentResponse: initialResponse}
|
|
| 29 |
+} |
|
| 30 |
+ |
|
| 27 | 31 |
func (r *resumableRequestReader) Read(p []byte) (n int, err error) {
|
| 28 | 32 |
if r.client == nil || r.request == nil {
|
| 29 | 33 |
return 0, fmt.Errorf("client and request can't be nil\n")
|