mirror of
https://github.com/versity/versitygw.git
synced 2025-12-23 13:15:18 +00:00
fix: Fixes the signed chunk trailer encoding to return proper api errors for invalid and incorrect checksums.
Fixes #1165 The signed chunk encoding with trailers should return api error for: 1. Invalid checksum - `(InvalidRequest) Value for x-amz-checksum-x trailing header is invalid.` 2. Incorrect checksum - `(BadDigest) The x you specified did not match the calculated checksum.` Where `x` could be crc32, crc32c, sha1 ...
This commit is contained in:
@@ -770,6 +770,14 @@ func GetInvalidChecksumHeaderErr(header string) APIError {
|
||||
}
|
||||
}
|
||||
|
||||
func GetInvalidTrailingChecksumHeaderErr(header string) APIError {
|
||||
return APIError{
|
||||
Code: "InvalidRequest",
|
||||
Description: fmt.Sprintf("Value for %v trailing header is invalid.", header),
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}
|
||||
}
|
||||
|
||||
// Returns checksum type mismatch APIError
|
||||
func GetChecksumTypeMismatchErr(expected, actual types.ChecksumAlgorithm) APIError {
|
||||
return APIError{
|
||||
@@ -783,7 +791,7 @@ func GetChecksumTypeMismatchErr(expected, actual types.ChecksumAlgorithm) APIErr
|
||||
func GetChecksumBadDigestErr(algo types.ChecksumAlgorithm) APIError {
|
||||
return APIError{
|
||||
Code: "BadDigest",
|
||||
Description: fmt.Sprintf("The %v you specified did not match the calculated checksum.", strings.ToLower(string(algo))),
|
||||
Description: fmt.Sprintf("The %v you specified did not match the calculated checksum.", algo),
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user