add support for specific error response for InvalidRange (#19668)

fixes #19648

AWS S3 returns the actual object size as part of XML
response for InvalidRange error, this is used apparently
by SDKs to retry the request without the range.
This commit is contained in:
Harshavardhana
2024-05-05 09:56:21 -07:00
committed by GitHub
parent 8ff70ea5a9
commit 523bd769f1
6 changed files with 61 additions and 29 deletions

View File

@@ -595,7 +595,7 @@ type InvalidRange struct {
}
func (e InvalidRange) Error() string {
return fmt.Sprintf("The requested range \"bytes %d -> %d of %d\" is not satisfiable.", e.OffsetBegin, e.OffsetEnd, e.ResourceSize)
return fmt.Sprintf("The requested range 'bytes=%d-%d' is not satisfiable", e.OffsetBegin, e.OffsetEnd)
}
// ObjectTooLarge error returned when the size of the object > max object size allowed (5G) per request.
@@ -758,6 +758,9 @@ func isErrMethodNotAllowed(err error) bool {
}
func isErrInvalidRange(err error) bool {
if errors.Is(err, errInvalidRange) {
return true
}
_, ok := err.(InvalidRange)
return ok
}