From 9b865d86a9606b46e2299be7f8088d12d4f544d2 Mon Sep 17 00:00:00 2001 From: Bin Du Date: Tue, 5 Jun 2018 19:25:01 +0000 Subject: [PATCH] docker/pusher: handle location string containing path and query Signed-off-by: Bin Du --- remotes/docker/pusher.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/remotes/docker/pusher.go b/remotes/docker/pusher.go index e2caf7028..c3c0923f0 100644 --- a/remotes/docker/pusher.go +++ b/remotes/docker/pusher.go @@ -155,9 +155,18 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten location := resp.Header.Get("Location") // Support paths without host in location if strings.HasPrefix(location, "/") { - u := p.base - u.Path = location - location = u.String() + // Support location string containing path and query + qmIndex := strings.Index(location, "?") + if qmIndex > 0 { + u := p.base + u.Path = location[:qmIndex] + u.RawQuery = location[qmIndex+1:] + location = u.String() + } else { + u := p.base + u.Path = location + location = u.String() + } } req, err = http.NewRequest(http.MethodPut, location, nil)