Merge pull request #7272 from unclejack/create_httputils_pkg

move resumablerequestreader to pkg/httputils
This commit is contained in:
Victor Vieux 2014-07-29 12:18:10 -07:00
commit 3bae02cbe3
3 changed files with 6 additions and 3 deletions

View file

@ -0,0 +1 @@
Cristian Staretu <cristian.staretu@gmail.com> (@unclejack)

View file

@ -1,8 +1,9 @@
package utils
package httputils
import (
"fmt"
"io"
"log"
"net/http"
"time"
)
@ -70,7 +71,7 @@ func (r *resumableRequestReader) Read(p []byte) (n int, err error) {
r.cleanUpResponse()
}
if err != nil && err != io.EOF {
Debugf("encountered error during pull and clearing it before resume: %s", err)
log.Printf("encountered error during pull and clearing it before resume: %s", err)
err = nil
}
return n, err

View file

@ -24,6 +24,7 @@ import (
"time"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/pkg/httputils"
"github.com/docker/docker/utils"
)
@ -423,7 +424,7 @@ func (r *Registry) GetRemoteImageLayer(imgID, registry string, token []string, i
if res.Header.Get("Accept-Ranges") == "bytes" && imgSize > 0 {
utils.Debugf("server supports resume")
return utils.ResumableRequestReaderWithInitialResponse(client, req, 5, imgSize, res), nil
return httputils.ResumableRequestReaderWithInitialResponse(client, req, 5, imgSize, res), nil
}
utils.Debugf("server doesn't support resume")
return res.Body, nil