@@ -22,8 +22,8 @@ import (
2222 "github.com/Sirupsen/logrus"
2323 "github.com/docker/docker/cliconfig"
2424 "github.com/docker/docker/pkg/httputils"
25+ "github.com/docker/docker/pkg/ioutils"
2526 "github.com/docker/docker/pkg/tarsum"
26- "github.com/docker/docker/pkg/transport"
2727)
2828
2929var (
@@ -73,6 +73,21 @@ func AuthTransport(base http.RoundTripper, authConfig *cliconfig.AuthConfig, alw
7373 }
7474}
7575
76+ // cloneRequest returns a clone of the provided *http.Request.
77+ // The clone is a shallow copy of the struct and its Header map.
78+ func cloneRequest (r * http.Request ) * http.Request {
79+ // shallow copy of the struct
80+ r2 := new (http.Request )
81+ * r2 = * r
82+ // deep copy of the Header
83+ r2 .Header = make (http.Header , len (r .Header ))
84+ for k , s := range r .Header {
85+ r2 .Header [k ] = append ([]string (nil ), s ... )
86+ }
87+
88+ return r2
89+ }
90+
7691func (tr * authTransport ) RoundTrip (orig * http.Request ) (* http.Response , error ) {
7792 // Authorization should not be set on 302 redirect for untrusted locations.
7893 // This logic mirrors the behavior in AddRequiredHeadersToRedirectedRequests.
@@ -112,7 +127,7 @@ func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) {
112127 if len (resp .Header ["X-Docker-Token" ]) > 0 {
113128 tr .token = resp .Header ["X-Docker-Token" ]
114129 }
115- resp .Body = & transport .OnEOFReader {
130+ resp .Body = & ioutils .OnEOFReader {
116131 Rc : resp .Body ,
117132 Fn : func () {
118133 tr .mu .Lock ()
0 commit comments