@@ -313,13 +313,12 @@ func InitiateUploadBlob(ctx *context.Context) {
313313
314314 setResponseHeaders (ctx .Resp , & containerHeaders {
315315 Location : fmt .Sprintf ("/v2/%s/%s/blobs/uploads/%s" , ctx .Package .Owner .LowerName , image , upload .ID ),
316- Range : "0-0" ,
317316 UploadUUID : upload .ID ,
318317 Status : http .StatusAccepted ,
319318 })
320319}
321320
322- // https://docs.docker. com/registry/ spec/api/#get- blob-upload
321+ // https://github. com/opencontainers/distribution- spec/blob/main/spec.md#pushing-a- blob-in-chunks
323322func GetUploadBlob (ctx * context.Context ) {
324323 uuid := ctx .PathParam ("uuid" )
325324
@@ -334,12 +333,13 @@ func GetUploadBlob(ctx *context.Context) {
334333 }
335334
336335 setResponseHeaders (ctx .Resp , & containerHeaders {
337- Range : fmt .Sprintf ("0-%d" , upload .BytesReceived ),
336+ Range : fmt .Sprintf ("0-%d" , upload .BytesReceived - 1 ),
338337 UploadUUID : upload .ID ,
339338 Status : http .StatusNoContent ,
340339 })
341340}
342341
342+ // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#single-post
343343// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
344344func UploadBlob (ctx * context.Context ) {
345345 image := ctx .PathParam ("image" )
@@ -377,12 +377,15 @@ func UploadBlob(ctx *context.Context) {
377377 return
378378 }
379379
380- setResponseHeaders ( ctx . Resp , & containerHeaders {
380+ respHeaders := & containerHeaders {
381381 Location : fmt .Sprintf ("/v2/%s/%s/blobs/uploads/%s" , ctx .Package .Owner .LowerName , image , uploader .ID ),
382- Range : fmt .Sprintf ("0-%d" , uploader .Size ()- 1 ),
383382 UploadUUID : uploader .ID ,
384383 Status : http .StatusAccepted ,
385- })
384+ }
385+ if contentRange != "" {
386+ respHeaders .Range = fmt .Sprintf ("0-%d" , uploader .Size ()- 1 )
387+ }
388+ setResponseHeaders (ctx .Resp , respHeaders )
386389}
387390
388391// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
0 commit comments