Skip to content

Commit e536fc1

Browse files
committed
fix
1 parent 0d3e995 commit e536fc1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

routers/api/packages/container/container.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ 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
})
@@ -334,7 +333,6 @@ func GetUploadBlob(ctx *context.Context) {
334333
}
335334

336335
setResponseHeaders(ctx.Resp, &containerHeaders{
337-
Range: fmt.Sprintf("0-%d", upload.BytesReceived),
338336
UploadUUID: upload.ID,
339337
Status: http.StatusNoContent,
340338
})
@@ -377,12 +375,15 @@ func UploadBlob(ctx *context.Context) {
377375
return
378376
}
379377

380-
setResponseHeaders(ctx.Resp, &containerHeaders{
378+
respHeaders := &containerHeaders{
381379
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),
383380
UploadUUID: uploader.ID,
384381
Status: http.StatusAccepted,
385-
})
382+
}
383+
if contentRange != "" {
384+
respHeaders.Range = fmt.Sprintf("0-%d", uploader.Size()-1)
385+
}
386+
setResponseHeaders(ctx.Resp, respHeaders)
386387
}
387388

388389
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks

0 commit comments

Comments
 (0)