mirror of
https://github.com/containers/skopeo.git
synced 2025-06-27 23:27:29 +00:00
Merge pull request #65 from runcom/fix-headers
provide a way to pass multi values-single key headers
This commit is contained in:
commit
532fae24ac
@ -78,7 +78,7 @@ func newDockerClient(refHostname, certPath string, tlsVerify bool) (*dockerClien
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *dockerClient) makeRequest(method, url string, headers map[string]string, stream io.Reader) (*http.Response, error) {
|
||||
func (c *dockerClient) makeRequest(method, url string, headers map[string][]string, stream io.Reader) (*http.Response, error) {
|
||||
if c.scheme == "" {
|
||||
pr, err := c.ping()
|
||||
if err != nil {
|
||||
@ -95,7 +95,9 @@ func (c *dockerClient) makeRequest(method, url string, headers map[string]string
|
||||
}
|
||||
req.Header.Set("Docker-Distribution-API-Version", "registry/2.0")
|
||||
for n, h := range headers {
|
||||
req.Header.Add(n, h)
|
||||
for _, hh := range h {
|
||||
req.Header.Add(n, hh)
|
||||
}
|
||||
}
|
||||
if c.wwwAuthenticate != "" {
|
||||
if err := c.setupRequestAuth(req); err != nil {
|
||||
|
@ -49,10 +49,10 @@ func (d *dockerImageDestination) PutManifest(manifest []byte) error {
|
||||
}
|
||||
url := fmt.Sprintf(manifestURL, d.ref.RemoteName(), digest)
|
||||
|
||||
headers := map[string]string{}
|
||||
headers := map[string][]string{}
|
||||
mimeType := utils.GuessManifestMIMEType(manifest)
|
||||
if mimeType != "" {
|
||||
headers["Content-Type"] = mimeType
|
||||
headers["Content-Type"] = []string{mimeType}
|
||||
}
|
||||
res, err := d.c.makeRequest("PUT", url, headers, bytes.NewReader(manifest))
|
||||
if err != nil {
|
||||
@ -89,7 +89,7 @@ func (d *dockerImageDestination) PutLayer(digest string, stream io.Reader) error
|
||||
uploadURL := fmt.Sprintf(blobUploadURL, d.ref.RemoteName(), digest)
|
||||
logrus.Debugf("Uploading %s", uploadURL)
|
||||
// FIXME: Set Content-Length?
|
||||
res, err = d.c.makeRequest("POST", uploadURL, map[string]string{"Content-Type": "application/octet-stream"}, stream)
|
||||
res, err = d.c.makeRequest("POST", uploadURL, map[string][]string{"Content-Type": {"application/octet-stream"}}, stream)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user