mirror of
https://github.com/distribution/distribution.git
synced 2025-08-22 16:46:51 +00:00
Merge pull request #6 from digitalocean/wwarren/oci-compliance-post-request-wtih-digest-and-blob-should-yield-201
OCI: POST request with digest and blob should yield 201
This commit is contained in:
commit
a68e2a8111
@ -29,9 +29,9 @@ func blobUploadDispatcher(ctx *Context, r *http.Request) http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.readOnly {
|
if !ctx.readOnly {
|
||||||
handler["POST"] = http.HandlerFunc(buh.StartBlobUpload)
|
handler["POST"] = http.HandlerFunc(buh.PostBlobData)
|
||||||
handler["PATCH"] = http.HandlerFunc(buh.PatchBlobData)
|
handler["PATCH"] = http.HandlerFunc(buh.PatchBlobData)
|
||||||
handler["PUT"] = http.HandlerFunc(buh.PutBlobUploadComplete)
|
handler["PUT"] = http.HandlerFunc(buh.BlobUploadComplete)
|
||||||
handler["DELETE"] = http.HandlerFunc(buh.CancelBlobUpload)
|
handler["DELETE"] = http.HandlerFunc(buh.CancelBlobUpload)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +97,7 @@ func (buh *blobUploadHandler) StartBlobUpload(w http.ResponseWriter, r *http.Req
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Docker-Upload-UUID", buh.Upload.ID())
|
w.Header().Set("Docker-Upload-UUID", buh.Upload.ID())
|
||||||
|
|
||||||
w.WriteHeader(http.StatusAccepted)
|
w.WriteHeader(http.StatusAccepted)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,15 +149,24 @@ func (buh *blobUploadHandler) PatchBlobData(w http.ResponseWriter, r *http.Reque
|
|||||||
w.WriteHeader(http.StatusAccepted)
|
w.WriteHeader(http.StatusAccepted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutBlobUploadComplete takes the final request of a blob upload. The
|
// PostBlobData writes upload data to a blob.
|
||||||
// request may include all the blob data or no blob data. Any data
|
func (buh *blobUploadHandler) PostBlobData(w http.ResponseWriter, r *http.Request) {
|
||||||
// provided is received and verified. If successful, the blob is linked
|
if r.FormValue("digest") != "" && r.ContentLength > 0 {
|
||||||
// into the blob store and 201 Created is returned with the canonical
|
buh.BlobUploadComplete(w, r)
|
||||||
// url of the blob.
|
} else {
|
||||||
func (buh *blobUploadHandler) PutBlobUploadComplete(w http.ResponseWriter, r *http.Request) {
|
buh.StartBlobUpload(w, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BlobUploadComplete takes the final request of a blob upload. The request may
|
||||||
|
// include all the blob data or no blob data. Any data provided is received and
|
||||||
|
// verified. If successful, the blob is linked into the blob store and 201
|
||||||
|
// Created is returned with the canonical url of the blob.
|
||||||
|
func (buh *blobUploadHandler) BlobUploadComplete(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var err error
|
||||||
if buh.Upload == nil {
|
if buh.Upload == nil {
|
||||||
buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown)
|
blobs := buh.Repository.Blobs(buh)
|
||||||
return
|
buh.Upload, err = blobs.Create(buh)
|
||||||
}
|
}
|
||||||
|
|
||||||
dgstStr := r.FormValue("digest") // TODO(stevvooe): Support multiple digest parameters!
|
dgstStr := r.FormValue("digest") // TODO(stevvooe): Support multiple digest parameters!
|
||||||
|
Loading…
Reference in New Issue
Block a user