Skip to content

Commit b87dcd7

Browse files
committed
fix
1 parent 0d3e995 commit b87dcd7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

routers/api/packages/container/container.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ func InitiateUploadBlob(ctx *context.Context) {
312312
}
313313

314314
setResponseHeaders(ctx.Resp, &containerHeaders{
315-
Location: fmt.Sprintf("/v2/%s/%s/blobs/uploads/%s", ctx.Package.Owner.LowerName, image, upload.ID),
316-
Range: "0-0",
315+
Location: fmt.Sprintf("/v2/%s/%s/blobs/uploads/%s", ctx.Package.Owner.LowerName, image, upload.ID),
316+
// Range: "0-0", // FIXME: why it is needed? Spec doesn't mention it, and it is not right: "0-0" means the first byte (len=1)
317317
UploadUUID: upload.ID,
318318
Status: http.StatusAccepted,
319319
})
@@ -334,7 +334,7 @@ func GetUploadBlob(ctx *context.Context) {
334334
}
335335

336336
setResponseHeaders(ctx.Resp, &containerHeaders{
337-
Range: fmt.Sprintf("0-%d", upload.BytesReceived),
337+
// Range: fmt.Sprintf("0-%d", upload.BytesReceived), // FIXME: not right, the "range end" should be "len-1"
338338
UploadUUID: upload.ID,
339339
Status: http.StatusNoContent,
340340
})
@@ -378,8 +378,8 @@ func UploadBlob(ctx *context.Context) {
378378
}
379379

380380
setResponseHeaders(ctx.Resp, &containerHeaders{
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),
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), // FIXME: not right, when "uploader.Size()" is 0, it results in "0--1" which is not a valid range
383383
UploadUUID: uploader.ID,
384384
Status: http.StatusAccepted,
385385
})

tests/integration/api_packages_container_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func TestPackageContainer(t *testing.T) {
302302
resp = MakeRequest(t, req, http.StatusAccepted)
303303

304304
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid"))
305-
assert.Equal(t, contentRange, resp.Header().Get("Range"))
305+
// assert.Equal(t, contentRange, resp.Header().Get("Range"))
306306

307307
uploadURL = resp.Header().Get("Location")
308308

@@ -311,7 +311,7 @@ func TestPackageContainer(t *testing.T) {
311311
resp = MakeRequest(t, req, http.StatusNoContent)
312312

313313
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid"))
314-
assert.Equal(t, fmt.Sprintf("0-%d", len(blobContent)), resp.Header().Get("Range"))
314+
// assert.Equal(t, fmt.Sprintf("0-%d", len(blobContent)), resp.Header().Get("Range"))
315315

316316
pbu, err = packages_model.GetBlobUploadByID(db.DefaultContext, uuid)
317317
assert.NoError(t, err)
@@ -342,7 +342,7 @@ func TestPackageContainer(t *testing.T) {
342342
resp = MakeRequest(t, req, http.StatusNoContent)
343343

344344
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid"))
345-
assert.Equal(t, "0-0", resp.Header().Get("Range"))
345+
// assert.Equal(t, "0-0", resp.Header().Get("Range"))
346346

347347
req = NewRequest(t, "DELETE", setting.AppURL+uploadURL[1:]).
348348
AddTokenAuth(userToken)

0 commit comments

Comments
 (0)