remove pkg/transport and use the one from distribution

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2015-05-17 05:07:48 -04:00
parent 45bd073e54
commit 950cf586c8
4 changed files with 21 additions and 6 deletions

View file

@ -11,7 +11,7 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/distribution/registry/api/v2" "github.com/docker/distribution/registry/api/v2"
"github.com/docker/docker/pkg/transport" "github.com/docker/distribution/registry/client/transport"
) )
// for mocking in unit tests // for mocking in unit tests

View file

@ -17,11 +17,11 @@ import (
"time" "time"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/distribution/registry/client/transport"
"github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/autogen/dockerversion"
"github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/timeoutconn" "github.com/docker/docker/pkg/timeoutconn"
"github.com/docker/docker/pkg/tlsconfig" "github.com/docker/docker/pkg/tlsconfig"
"github.com/docker/docker/pkg/transport"
"github.com/docker/docker/pkg/useragent" "github.com/docker/docker/pkg/useragent"
) )
@ -92,7 +92,7 @@ func (m *httpsRequestModifier) ModifyRequest(req *http.Request) error {
logrus.Debugf("hostDir: %s", hostDir) logrus.Debugf("hostDir: %s", hostDir)
fs, err := ioutil.ReadDir(hostDir) fs, err := ioutil.ReadDir(hostDir)
if err != nil && !os.IsNotExist(err) { if err != nil && !os.IsNotExist(err) {
return nil return err
} }
for _, f := range fs { for _, f := range fs {

View file

@ -8,8 +8,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/distribution/registry/client/transport"
"github.com/docker/docker/cliconfig" "github.com/docker/docker/cliconfig"
"github.com/docker/docker/pkg/transport"
) )
var ( var (

View file

@ -22,8 +22,8 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/cliconfig" "github.com/docker/docker/cliconfig"
"github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/httputils"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/pkg/tarsum"
"github.com/docker/docker/pkg/transport"
) )
var ( var (
@ -73,6 +73,21 @@ func AuthTransport(base http.RoundTripper, authConfig *cliconfig.AuthConfig, alw
} }
} }
// cloneRequest returns a clone of the provided *http.Request.
// The clone is a shallow copy of the struct and its Header map.
func cloneRequest(r *http.Request) *http.Request {
// shallow copy of the struct
r2 := new(http.Request)
*r2 = *r
// deep copy of the Header
r2.Header = make(http.Header, len(r.Header))
for k, s := range r.Header {
r2.Header[k] = append([]string(nil), s...)
}
return r2
}
func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) { func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) {
// Authorization should not be set on 302 redirect for untrusted locations. // Authorization should not be set on 302 redirect for untrusted locations.
// This logic mirrors the behavior in AddRequiredHeadersToRedirectedRequests. // This logic mirrors the behavior in AddRequiredHeadersToRedirectedRequests.
@ -112,7 +127,7 @@ func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) {
if len(resp.Header["X-Docker-Token"]) > 0 { if len(resp.Header["X-Docker-Token"]) > 0 {
tr.token = resp.Header["X-Docker-Token"] tr.token = resp.Header["X-Docker-Token"]
} }
resp.Body = &transport.OnEOFReader{ resp.Body = &ioutils.OnEOFReader{
Rc: resp.Body, Rc: resp.Body,
Fn: func() { Fn: func() {
tr.mu.Lock() tr.mu.Lock()