0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

Remove from Response header Range the 'bytes' string

Conformance spec requires responding to PATCH requests with
response header 'Content-Range' and value <range>

Signed-off-by: Bogdan BIVOLARU <104334+bogdanbiv@users.noreply.github.com>
This commit is contained in:
Bogdan BIVOLARU 2022-06-29 11:12:20 +03:00 committed by Andrei Aaron
parent f92e584301
commit 0f386f0c89
5 changed files with 14 additions and 14 deletions

View file

@ -725,7 +725,7 @@ func (rh *RouteHandler) DeleteBlob(response http.ResponseWriter, request *http.R
// @Param name path string true "repository name"
// @Success 202 {string} string "accepted"
// @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}"
// @Header 202 {string} Range "bytes=0-0"
// @Header 202 {string} Range "0-0"
// @Failure 404 {string} string "not found"
// @Failure 500 {string} string "internal server error"
// @Router /v2/{name}/blobs/uploads [post].
@ -767,7 +767,7 @@ func (rh *RouteHandler) CreateBlobUpload(response http.ResponseWriter, request *
}
response.Header().Set("Location", getBlobUploadSessionLocation(request.URL, upload))
response.Header().Set("Range", "bytes=0-0")
response.Header().Set("Range", "0-0")
response.WriteHeader(http.StatusAccepted)
return
@ -853,7 +853,7 @@ func (rh *RouteHandler) CreateBlobUpload(response http.ResponseWriter, request *
}
response.Header().Set("Location", getBlobUploadSessionLocation(request.URL, upload))
response.Header().Set("Range", "bytes=0-0")
response.Header().Set("Range", "0-0")
response.WriteHeader(http.StatusAccepted)
}
@ -866,7 +866,7 @@ func (rh *RouteHandler) CreateBlobUpload(response http.ResponseWriter, request *
// @Param session_id path string true "upload session_id"
// @Success 204 {string} string "no content"
// @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}"
// @Header 202 {string} Range "bytes=0-128"
// @Header 202 {string} Range "0-128"
// @Failure 404 {string} string "not found"
// @Failure 500 {string} string "internal server error"
// @Router /v2/{name}/blobs/uploads/{session_id} [get].
@ -912,7 +912,7 @@ func (rh *RouteHandler) GetBlobUpload(response http.ResponseWriter, request *htt
}
response.Header().Set("Location", getBlobUploadSessionLocation(request.URL, sessionID))
response.Header().Set("Range", fmt.Sprintf("bytes=0-%d", size-1))
response.Header().Set("Range", fmt.Sprintf("0-%d", size-1))
response.WriteHeader(http.StatusNoContent)
}
@ -925,7 +925,7 @@ func (rh *RouteHandler) GetBlobUpload(response http.ResponseWriter, request *htt
// @Param session_id path string true "upload session_id"
// @Success 202 {string} string "accepted"
// @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}"
// @Header 202 {string} Range "bytes=0-128"
// @Header 202 {string} Range "0-128"
// @Header 200 {object} api.BlobUploadUUID
// @Failure 400 {string} string "bad request"
// @Failure 404 {string} string "not found"
@ -1004,7 +1004,7 @@ func (rh *RouteHandler) PatchBlobUpload(response http.ResponseWriter, request *h
}
response.Header().Set("Location", getBlobUploadSessionLocation(request.URL, sessionID))
response.Header().Set("Range", fmt.Sprintf("bytes=0-%d", clen-1))
response.Header().Set("Range", fmt.Sprintf("0-%d", clen-1))
response.Header().Set("Content-Length", "0")
response.Header().Set(constants.BlobUploadUUID, sessionID)
response.WriteHeader(http.StatusAccepted)

View file

@ -289,7 +289,7 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) {
So(resp.StatusCode(), ShouldEqual, http.StatusNoContent)
r := resp.Header().Get("Range")
So(r, ShouldNotBeEmpty)
So(r, ShouldEqual, "bytes="+contentRange)
So(r, ShouldEqual, contentRange)
// write same chunk should fail
contentRange = fmt.Sprintf("%d-%d", 0, len(chunk1)-1)
@ -357,7 +357,7 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) {
So(resp.StatusCode(), ShouldEqual, http.StatusNoContent)
r := resp.Header().Get("Range")
So(r, ShouldNotBeEmpty)
So(r, ShouldEqual, "bytes="+contentRange)
So(r, ShouldEqual, contentRange)
// write same chunk should fail
contentRange = fmt.Sprintf("%d-%d", 0, len(chunk1)-1)

View file

@ -186,7 +186,7 @@ var doc = `{
},
"Range": {
"type": "string",
"description": "bytes=0-0"
"description": "0-0"
}
}
},

View file

@ -168,7 +168,7 @@
},
"Range": {
"type": "string",
"description": "bytes=0-0"
"description": "0-0"
}
}
},
@ -371,7 +371,7 @@
},
"Range": {
"type": "string",
"description": "bytes=0-128"
"description": "0-128"
}
}
},

View file

@ -206,7 +206,7 @@ paths:
description: /v2/{name}/blobs/uploads/{session_id}
type: string
Range:
description: bytes=0-0
description: 0-0
type: string
schema:
type: string
@ -307,7 +307,7 @@ paths:
description: /v2/{name}/blobs/uploads/{session_id}
type: string
Range:
description: bytes=0-128
description: 0-128
type: string
schema:
type: string