mirror of
https://github.com/minio/minio.git
synced 2025-04-07 21:25:36 -04:00
fix: calculate correct content-range with partNumber query (#11992)
fixes #11989 fixes #11824
This commit is contained in:
parent
4223ebab8d
commit
0b33fa50ae
@ -82,6 +82,7 @@ const (
|
|||||||
ErrInvalidBucketName
|
ErrInvalidBucketName
|
||||||
ErrInvalidDigest
|
ErrInvalidDigest
|
||||||
ErrInvalidRange
|
ErrInvalidRange
|
||||||
|
ErrInvalidRangePartNumber
|
||||||
ErrInvalidCopyPartRange
|
ErrInvalidCopyPartRange
|
||||||
ErrInvalidCopyPartRangeSource
|
ErrInvalidCopyPartRangeSource
|
||||||
ErrInvalidMaxKeys
|
ErrInvalidMaxKeys
|
||||||
@ -505,6 +506,11 @@ var errorCodes = errorCodeMap{
|
|||||||
Description: "The requested range is not satisfiable",
|
Description: "The requested range is not satisfiable",
|
||||||
HTTPStatusCode: http.StatusRequestedRangeNotSatisfiable,
|
HTTPStatusCode: http.StatusRequestedRangeNotSatisfiable,
|
||||||
},
|
},
|
||||||
|
ErrInvalidRangePartNumber: {
|
||||||
|
Code: "InvalidRequest",
|
||||||
|
Description: "Cannot specify both Range header and partNumber query parameter",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
ErrMalformedXML: {
|
ErrMalformedXML: {
|
||||||
Code: "MalformedXML",
|
Code: "MalformedXML",
|
||||||
Description: "The XML you provided was not well-formed or did not validate against our published schema.",
|
Description: "The XML you provided was not well-formed or did not validate against our published schema.",
|
||||||
|
@ -158,16 +158,16 @@ func setObjectHeaders(w http.ResponseWriter, objInfo ObjectInfo, rs *HTTPRangeSp
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rs == nil && opts.PartNumber > 0 {
|
||||||
|
rs = partNumberToRangeSpec(objInfo, opts.PartNumber)
|
||||||
|
}
|
||||||
|
|
||||||
// For providing ranged content
|
// For providing ranged content
|
||||||
start, rangeLen, err = rs.GetOffsetLength(totalObjectSize)
|
start, rangeLen, err = rs.GetOffsetLength(totalObjectSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs == nil && opts.PartNumber > 0 {
|
|
||||||
rs = partNumberToRangeSpec(objInfo, opts.PartNumber)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set content length.
|
// Set content length.
|
||||||
w.Header().Set(xhttp.ContentLength, strconv.FormatInt(rangeLen, 10))
|
w.Header().Set(xhttp.ContentLength, strconv.FormatInt(rangeLen, 10))
|
||||||
if rs != nil {
|
if rs != nil {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -400,7 +400,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
|||||||
|
|
||||||
// Both 'bytes' and 'partNumber' cannot be specified at the same time
|
// Both 'bytes' and 'partNumber' cannot be specified at the same time
|
||||||
if rs != nil && opts.PartNumber > 0 {
|
if rs != nil && opts.PartNumber > 0 {
|
||||||
writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(ErrBadRequest))
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidRangePartNumber), r.URL, guessIsBrowserReq(r))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,7 +694,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
|
|||||||
|
|
||||||
// Both 'bytes' and 'partNumber' cannot be specified at the same time
|
// Both 'bytes' and 'partNumber' cannot be specified at the same time
|
||||||
if rs != nil && opts.PartNumber > 0 {
|
if rs != nil && opts.PartNumber > 0 {
|
||||||
writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(ErrBadRequest))
|
writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(ErrInvalidRangePartNumber))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user