mirror of
https://github.com/project-zot/zot.git
synced 2025-01-13 22:50:38 -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:
parent
f92e584301
commit
0f386f0c89
5 changed files with 14 additions and 14 deletions
|
@ -725,7 +725,7 @@ func (rh *RouteHandler) DeleteBlob(response http.ResponseWriter, request *http.R
|
||||||
// @Param name path string true "repository name"
|
// @Param name path string true "repository name"
|
||||||
// @Success 202 {string} string "accepted"
|
// @Success 202 {string} string "accepted"
|
||||||
// @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}"
|
// @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 404 {string} string "not found"
|
||||||
// @Failure 500 {string} string "internal server error"
|
// @Failure 500 {string} string "internal server error"
|
||||||
// @Router /v2/{name}/blobs/uploads [post].
|
// @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("Location", getBlobUploadSessionLocation(request.URL, upload))
|
||||||
response.Header().Set("Range", "bytes=0-0")
|
response.Header().Set("Range", "0-0")
|
||||||
response.WriteHeader(http.StatusAccepted)
|
response.WriteHeader(http.StatusAccepted)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -853,7 +853,7 @@ func (rh *RouteHandler) CreateBlobUpload(response http.ResponseWriter, request *
|
||||||
}
|
}
|
||||||
|
|
||||||
response.Header().Set("Location", getBlobUploadSessionLocation(request.URL, upload))
|
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)
|
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"
|
// @Param session_id path string true "upload session_id"
|
||||||
// @Success 204 {string} string "no content"
|
// @Success 204 {string} string "no content"
|
||||||
// @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}"
|
// @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 404 {string} string "not found"
|
||||||
// @Failure 500 {string} string "internal server error"
|
// @Failure 500 {string} string "internal server error"
|
||||||
// @Router /v2/{name}/blobs/uploads/{session_id} [get].
|
// @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("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)
|
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"
|
// @Param session_id path string true "upload session_id"
|
||||||
// @Success 202 {string} string "accepted"
|
// @Success 202 {string} string "accepted"
|
||||||
// @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}"
|
// @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
|
// @Header 200 {object} api.BlobUploadUUID
|
||||||
// @Failure 400 {string} string "bad request"
|
// @Failure 400 {string} string "bad request"
|
||||||
// @Failure 404 {string} string "not found"
|
// @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("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("Content-Length", "0")
|
||||||
response.Header().Set(constants.BlobUploadUUID, sessionID)
|
response.Header().Set(constants.BlobUploadUUID, sessionID)
|
||||||
response.WriteHeader(http.StatusAccepted)
|
response.WriteHeader(http.StatusAccepted)
|
||||||
|
|
|
@ -289,7 +289,7 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) {
|
||||||
So(resp.StatusCode(), ShouldEqual, http.StatusNoContent)
|
So(resp.StatusCode(), ShouldEqual, http.StatusNoContent)
|
||||||
r := resp.Header().Get("Range")
|
r := resp.Header().Get("Range")
|
||||||
So(r, ShouldNotBeEmpty)
|
So(r, ShouldNotBeEmpty)
|
||||||
So(r, ShouldEqual, "bytes="+contentRange)
|
So(r, ShouldEqual, contentRange)
|
||||||
|
|
||||||
// write same chunk should fail
|
// write same chunk should fail
|
||||||
contentRange = fmt.Sprintf("%d-%d", 0, len(chunk1)-1)
|
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)
|
So(resp.StatusCode(), ShouldEqual, http.StatusNoContent)
|
||||||
r := resp.Header().Get("Range")
|
r := resp.Header().Get("Range")
|
||||||
So(r, ShouldNotBeEmpty)
|
So(r, ShouldNotBeEmpty)
|
||||||
So(r, ShouldEqual, "bytes="+contentRange)
|
So(r, ShouldEqual, contentRange)
|
||||||
|
|
||||||
// write same chunk should fail
|
// write same chunk should fail
|
||||||
contentRange = fmt.Sprintf("%d-%d", 0, len(chunk1)-1)
|
contentRange = fmt.Sprintf("%d-%d", 0, len(chunk1)-1)
|
||||||
|
|
|
@ -186,7 +186,7 @@ var doc = `{
|
||||||
},
|
},
|
||||||
"Range": {
|
"Range": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "bytes=0-0"
|
"description": "0-0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -168,7 +168,7 @@
|
||||||
},
|
},
|
||||||
"Range": {
|
"Range": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "bytes=0-0"
|
"description": "0-0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -371,7 +371,7 @@
|
||||||
},
|
},
|
||||||
"Range": {
|
"Range": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "bytes=0-128"
|
"description": "0-128"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -206,7 +206,7 @@ paths:
|
||||||
description: /v2/{name}/blobs/uploads/{session_id}
|
description: /v2/{name}/blobs/uploads/{session_id}
|
||||||
type: string
|
type: string
|
||||||
Range:
|
Range:
|
||||||
description: bytes=0-0
|
description: 0-0
|
||||||
type: string
|
type: string
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
@ -307,7 +307,7 @@ paths:
|
||||||
description: /v2/{name}/blobs/uploads/{session_id}
|
description: /v2/{name}/blobs/uploads/{session_id}
|
||||||
type: string
|
type: string
|
||||||
Range:
|
Range:
|
||||||
description: bytes=0-128
|
description: 0-128
|
||||||
type: string
|
type: string
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
|
Loading…
Add table
Reference in a new issue