Browse code

resumablerequestreader: allow initial response

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)

unclejack authored on 2014/06/27 21:04:28
Showing 1 changed files
... ...
@@ -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")