mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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)
This commit is contained in:
parent
8365abb200
commit
f033ce3ee9
1 changed files with 4 additions and 0 deletions
|
@ -24,6 +24,10 @@ func ResumableRequestReader(c *http.Client, r *http.Request, maxfail uint32, tot
|
||||||
return &resumableRequestReader{client: c, request: r, maxFailures: maxfail, totalSize: totalsize}
|
return &resumableRequestReader{client: c, request: r, maxFailures: maxfail, totalSize: totalsize}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ResumableRequestReaderWithInitialResponse(c *http.Client, r *http.Request, maxfail uint32, totalsize int64, initialResponse *http.Response) io.ReadCloser {
|
||||||
|
return &resumableRequestReader{client: c, request: r, maxFailures: maxfail, totalSize: totalsize, currentResponse: initialResponse}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *resumableRequestReader) Read(p []byte) (n int, err error) {
|
func (r *resumableRequestReader) Read(p []byte) (n int, err error) {
|
||||||
if r.client == nil || r.request == nil {
|
if r.client == nil || r.request == nil {
|
||||||
return 0, fmt.Errorf("client and request can't be nil\n")
|
return 0, fmt.Errorf("client and request can't be nil\n")
|
||||||
|
|
Loading…
Reference in a new issue