Remove unused range parsing code and update tests (#6530)
This commit is contained in:
committed by
Nitish Tiwari
parent
1111419d4a
commit
387584356f
@@ -43,34 +43,6 @@ func writeCopyPartErr(w http.ResponseWriter, err error, url *url.URL) {
|
||||
// http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPartCopy.html
|
||||
// for full details. This function treats an empty rangeString as
|
||||
// referring to the whole resource.
|
||||
//
|
||||
// In addition to parsing the range string, it also validates the
|
||||
// specified range against the given object size, so that Copy API
|
||||
// specific error can be returned.
|
||||
func parseCopyPartRange(rangeString string, resourceSize int64) (offset, length int64, err error) {
|
||||
var hrange *HTTPRangeSpec
|
||||
if rangeString != "" {
|
||||
hrange, err = parseRequestRangeSpec(rangeString)
|
||||
if err != nil {
|
||||
return -1, -1, err
|
||||
}
|
||||
|
||||
// Require that both start and end are specified.
|
||||
if hrange.IsSuffixLength || hrange.Start == -1 || hrange.End == -1 {
|
||||
return -1, -1, errInvalidRange
|
||||
}
|
||||
|
||||
// Validate specified range against object size.
|
||||
if hrange.Start >= resourceSize || hrange.End >= resourceSize {
|
||||
return -1, -1, errInvalidRangeSource
|
||||
}
|
||||
}
|
||||
|
||||
return hrange.GetOffsetLength(resourceSize)
|
||||
}
|
||||
|
||||
// parseCopyPartRangeSpec transforms a range string (e.g. bytes=3-4) to HTTPRangeSpec
|
||||
// and returns errors if weird values
|
||||
func parseCopyPartRangeSpec(rangeString string) (hrange *HTTPRangeSpec, err error) {
|
||||
hrange, err = parseRequestRangeSpec(rangeString)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user