@@ -313,13 +313,12 @@ func InitiateUploadBlob(ctx *context.Context) {
313
313
314
314
setResponseHeaders (ctx .Resp , & containerHeaders {
315
315
Location : fmt .Sprintf ("/v2/%s/%s/blobs/uploads/%s" , ctx .Package .Owner .LowerName , image , upload .ID ),
316
- Range : "0-0" ,
317
316
UploadUUID : upload .ID ,
318
317
Status : http .StatusAccepted ,
319
318
})
320
319
}
321
320
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
323
322
func GetUploadBlob (ctx * context.Context ) {
324
323
uuid := ctx .PathParam ("uuid" )
325
324
@@ -334,12 +333,13 @@ func GetUploadBlob(ctx *context.Context) {
334
333
}
335
334
336
335
setResponseHeaders (ctx .Resp , & containerHeaders {
337
- Range : fmt .Sprintf ("0-%d" , upload .BytesReceived ),
336
+ Range : fmt .Sprintf ("0-%d" , upload .BytesReceived - 1 ),
338
337
UploadUUID : upload .ID ,
339
338
Status : http .StatusNoContent ,
340
339
})
341
340
}
342
341
342
+ // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#single-post
343
343
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
344
344
func UploadBlob (ctx * context.Context ) {
345
345
image := ctx .PathParam ("image" )
@@ -377,12 +377,15 @@ func UploadBlob(ctx *context.Context) {
377
377
return
378
378
}
379
379
380
- setResponseHeaders ( ctx . Resp , & containerHeaders {
380
+ respHeaders := & containerHeaders {
381
381
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 ),
383
382
UploadUUID : uploader .ID ,
384
383
Status : http .StatusAccepted ,
385
- })
384
+ }
385
+ if contentRange != "" {
386
+ respHeaders .Range = fmt .Sprintf ("0-%d" , uploader .Size ()- 1 )
387
+ }
388
+ setResponseHeaders (ctx .Resp , respHeaders )
386
389
}
387
390
388
391
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
0 commit comments