docker/pusher: handle location string containing path and query

Signed-off-by: Bin Du <bindu@microsoft.com>
This commit is contained in:
Bin Du 2018-06-05 19:25:01 +00:00
parent 081b2d6330
commit 9b865d86a9

View File

@ -155,9 +155,18 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
location := resp.Header.Get("Location") location := resp.Header.Get("Location")
// Support paths without host in location // Support paths without host in location
if strings.HasPrefix(location, "/") { if strings.HasPrefix(location, "/") {
u := p.base // Support location string containing path and query
u.Path = location qmIndex := strings.Index(location, "?")
location = u.String() 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) req, err = http.NewRequest(http.MethodPut, location, nil)