diff --git a/api/server/httputils/httputils.go b/api/server/httputils/httputils.go index d37ee5cafe..2c2e8452f9 100644 --- a/api/server/httputils/httputils.go +++ b/api/server/httputils/httputils.go @@ -14,9 +14,6 @@ import ( // APIVersionKey is the client's requested API version. const APIVersionKey = "api-version" -// UAStringKey is used as key type for user-agent string in net/context struct -const UAStringKey = "upstream-user-agent" - // APIFunc is an adapter to allow the use of ordinary functions as Docker API endpoints. // Any function that has the appropriate signature can be registered as an API endpoint (e.g. getVersion). type APIFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error diff --git a/api/server/server.go b/api/server/server.go index d988b8e17f..d8b716e100 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -12,6 +12,7 @@ import ( "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/server/middleware" "github.com/docker/docker/api/server/router" + "github.com/docker/docker/dockerversion" "github.com/gorilla/mux" "golang.org/x/net/context" ) @@ -128,7 +129,7 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc { // apply to all requests. Data that is specific to the // immediate function being called should still be passed // as 'args' on the function call. - ctx := context.WithValue(context.Background(), httputils.UAStringKey, r.Header.Get("User-Agent")) + ctx := context.WithValue(context.Background(), dockerversion.UAStringKey, r.Header.Get("User-Agent")) handlerFunc := s.handlerWithGlobalMiddlewares(handler) vars := mux.Vars(r) diff --git a/dockerversion/useragent.go b/dockerversion/useragent.go index d2a891c4d6..53632cbc35 100644 --- a/dockerversion/useragent.go +++ b/dockerversion/useragent.go @@ -4,12 +4,14 @@ import ( "fmt" "runtime" - "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/useragent" "golang.org/x/net/context" ) +// UAStringKey is used as key type for user-agent string in net/context struct +const UAStringKey = "upstream-user-agent" + // DockerUserAgent is the User-Agent the Docker client uses to identify itself. // In accordance with RFC 7231 (5.5.3) is of the form: // [docker client's UA] UpstreamClient([upstream client's UA]) @@ -37,9 +39,9 @@ func DockerUserAgent(ctx context.Context) string { func getUserAgentFromContext(ctx context.Context) string { var upstreamUA string if ctx != nil { - var ki interface{} = ctx.Value(httputils.UAStringKey) + var ki interface{} = ctx.Value(UAStringKey) if ki != nil { - upstreamUA = ctx.Value(httputils.UAStringKey).(string) + upstreamUA = ctx.Value(UAStringKey).(string) } } return upstreamUA