From 83977857f8d3df86bf5f905fc66f7bb5bc363dd6 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Tue, 6 Jan 2015 16:43:17 -0800 Subject: [PATCH] Correctly assemble URL during blob upload When adding parameters to a location header, the client must not destroy parameters already present. This change ensures that parameters are added, rather than replaced when assembling the url. Signed-off-by: Stephen J Day --- client/client.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/client.go b/client/client.go index f53c0e15..dba57da1 100644 --- a/client/client.go +++ b/client/client.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "net/http" - "net/url" "regexp" "strconv" @@ -398,9 +397,9 @@ func (r *clientImpl) UploadBlob(location string, blob io.ReadCloser, length int, return err } - queryValues := url.Values{} - queryValues.Set("digest", dgst.String()) - putRequest.URL.RawQuery = queryValues.Encode() + values := putRequest.URL.Query() + values.Set("digest", dgst.String()) + putRequest.URL.RawQuery = values.Encode() putRequest.Header.Set("Content-Type", "application/octet-stream") putRequest.Header.Set("Content-Length", fmt.Sprint(length)) @@ -486,9 +485,9 @@ func (r *clientImpl) FinishChunkedBlobUpload(location string, length int, dgst d return err } - queryValues := new(url.Values) - queryValues.Set("digest", dgst.String()) - putRequest.URL.RawQuery = queryValues.Encode() + values := putRequest.URL.Query() + values.Set("digest", dgst.String()) + putRequest.URL.RawQuery = values.Encode() putRequest.Header.Set("Content-Type", "application/octet-stream") putRequest.Header.Set("Content-Length", "0")