Merge pull request #2386 from northtyphoon/bindu/acr-push-location

docker/pusher: handle location string containing path and query
This commit is contained in:
Michael Crosby 2018-06-05 18:54:29 -04:00 committed by GitHub
commit 437e90aa5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)