Merge pull request #739 from stevvooe/etags-must-be-quoted
Etags must be quoted according to http spec
This commit is contained in:
commit
b49d77a42f
5 changed files with 16 additions and 14 deletions
|
@ -488,7 +488,7 @@ func testBlobAPI(t *testing.T, env *testEnv, args blobArgs) *testEnv {
|
|||
checkHeaders(t, resp, http.Header{
|
||||
"Content-Length": []string{fmt.Sprint(layerLength)},
|
||||
"Docker-Content-Digest": []string{canonicalDigest.String()},
|
||||
"ETag": []string{canonicalDigest.String()},
|
||||
"ETag": []string{fmt.Sprintf(`"%s"`, canonicalDigest)},
|
||||
"Cache-Control": []string{"max-age=31536000"},
|
||||
})
|
||||
|
||||
|
@ -499,6 +499,7 @@ func testBlobAPI(t *testing.T, env *testEnv, args blobArgs) *testEnv {
|
|||
t.Fatalf("Error constructing request: %s", err)
|
||||
}
|
||||
req.Header.Set("If-None-Match", etag)
|
||||
|
||||
resp, err = http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Error constructing request: %s", err)
|
||||
|
@ -835,7 +836,7 @@ func testManifestAPI(t *testing.T, env *testEnv, args manifestArgs) (*testEnv, m
|
|||
checkResponse(t, "fetching uploaded manifest", resp, http.StatusOK)
|
||||
checkHeaders(t, resp, http.Header{
|
||||
"Docker-Content-Digest": []string{dgst.String()},
|
||||
"ETag": []string{dgst.String()},
|
||||
"ETag": []string{fmt.Sprintf(`"%s"`, dgst)},
|
||||
})
|
||||
|
||||
var fetchedManifest manifest.SignedManifest
|
||||
|
@ -857,7 +858,7 @@ func testManifestAPI(t *testing.T, env *testEnv, args manifestArgs) (*testEnv, m
|
|||
checkResponse(t, "fetching uploaded manifest", resp, http.StatusOK)
|
||||
checkHeaders(t, resp, http.Header{
|
||||
"Docker-Content-Digest": []string{dgst.String()},
|
||||
"ETag": []string{dgst.String()},
|
||||
"ETag": []string{fmt.Sprintf(`"%s"`, dgst)},
|
||||
})
|
||||
|
||||
var fetchedManifestByDigest manifest.SignedManifest
|
||||
|
@ -1301,12 +1302,12 @@ func checkHeaders(t *testing.T, resp *http.Response, headers http.Header) {
|
|||
for _, v := range vs {
|
||||
if v == "*" {
|
||||
// Just ensure there is some value.
|
||||
if len(resp.Header[k]) > 0 {
|
||||
if len(resp.Header[http.CanonicalHeaderKey(k)]) > 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
for _, hv := range resp.Header[k] {
|
||||
for _, hv := range resp.Header[http.CanonicalHeaderKey(k)] {
|
||||
if hv != v {
|
||||
t.Fatalf("%+v %v header value not matched in response: %q != %q", resp.Header, k, hv, v)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue