diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 7fbbfd0e1..67df89ecd 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -376,6 +376,12 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj var rangeErr error rangeHeader := r.Header.Get(xhttp.Range) if rangeHeader != "" { + // Both 'Range' and 'partNumber' cannot be specified at the same time + if opts.PartNumber > 0 { + writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidRangePartNumber), r.URL) + return + } + rs, rangeErr = parseRequestRangeSpec(rangeHeader) // Handle only errInvalidRange. Ignore other // parse error and treat it as regular Get @@ -389,12 +395,6 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj } } - // Both 'bytes' and 'partNumber' cannot be specified at the same time - if rs != nil && opts.PartNumber > 0 { - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidRangePartNumber), r.URL) - return - } - // Validate pre-conditions if any. opts.CheckPrecondFn = func(oi ObjectInfo) bool { if objectAPI.IsEncryptionSupported() { @@ -703,6 +703,12 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob var rs *HTTPRangeSpec rangeHeader := r.Header.Get(xhttp.Range) if rangeHeader != "" { + // Both 'Range' and 'partNumber' cannot be specified at the same time + if opts.PartNumber > 0 { + writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(ErrInvalidRangePartNumber)) + return + } + if rs, err = parseRequestRangeSpec(rangeHeader); err != nil { // Handle only errInvalidRange. Ignore other // parse error and treat it as regular Get @@ -716,12 +722,6 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob } } - // Both 'bytes' and 'partNumber' cannot be specified at the same time - if rs != nil && opts.PartNumber > 0 { - writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(ErrInvalidRangePartNumber)) - return - } - // Set encryption response headers if objectAPI.IsEncryptionSupported() { switch kind, _ := crypto.IsEncrypted(objInfo.UserDefined); kind {