mirror of
https://github.com/versity/versitygw.git
synced 2025-12-23 05:05:16 +00:00
fix: Fixes GetObject and UploadPartCopy actions data range parsing.
Fixes #1004 Fixes #1122 Fixes #1120 Separates `GetObject` and `UploadPartCopy` range parsing/validation. `GetObject` returns a successful response if acceptRange is invalid. Adjusts the range upper limit, if it exceeds the actual objects size for `GetObject`. Corrects the `ContentRange` in the `GetObject` response. Fixes the `UploadPartCopy` action copy source range parsing/validation. `UploadPartCopy` returns `InvalidArgument` if the copy source range is not valid.
This commit is contained in:
@@ -83,6 +83,7 @@ const (
|
||||
ErrInternalError
|
||||
ErrInvalidCopyDest
|
||||
ErrInvalidCopySource
|
||||
ErrInvalidCopySourceRange
|
||||
ErrInvalidTag
|
||||
ErrAuthHeaderEmpty
|
||||
ErrSignatureVersionNotSupported
|
||||
@@ -296,6 +297,11 @@ var errorCodeResponse = map[ErrorCode]APIError{
|
||||
Description: "Copy Source must mention the source bucket and key: sourcebucket/sourcekey.",
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
},
|
||||
ErrInvalidCopySourceRange: {
|
||||
Code: "InvalidArgument",
|
||||
Description: "The x-amz-copy-source-range value must be of the form bytes=first-last where first and last are the zero-based offsets of the first and last bytes to copy",
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
},
|
||||
ErrInvalidTag: {
|
||||
Code: "InvalidArgument",
|
||||
Description: "The Tag value you have provided is invalid",
|
||||
@@ -791,3 +797,11 @@ func GetInvalidMpObjectSizeErr(val int64) APIError {
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}
|
||||
}
|
||||
|
||||
func CreateExceedingRangeErr(objSize int64) APIError {
|
||||
return APIError{
|
||||
Code: "InvalidArgument",
|
||||
Description: fmt.Sprintf("Range specified is not valid for source object of size: %d", objSize),
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user