Ignore the Range header when the method is different than GET
fix: bug when using Range header on PATCH/DELETE - Fix the "message": "syntax error at or near \"RETURNING\"" error - Fix doing a limited update/delete when an order query parameter was present breaking: The Range header is now only considered on GET requests and is ignored for any other method - Other methods should use the `limit/offset` query parameters for sub-ranges - PUT requests no longer return an error when this header is present
This commit is contained in:
@@ -237,10 +237,12 @@ getRanges :: ByteString -> QueryParams -> RequestHeaders -> Either ApiRequestErr
|
||||
getRanges method QueryParams{qsOrder,qsRanges} hdrs
|
||||
| isInvalidRange = Left $ InvalidRange (if rangeIsEmpty headerRange then LowerGTUpper else NegativeLimit)
|
||||
| method `elem` ["PATCH", "DELETE"] && not (null qsRanges) && null qsOrder = Left LimitNoOrderError
|
||||
| method == "PUT" && topLevelRange /= allRange = Left PutRangeNotAllowedError
|
||||
| method == "PUT" && topLevelRange /= allRange = Left PutLimitNotAllowedError
|
||||
| otherwise = Right (topLevelRange, ranges)
|
||||
where
|
||||
headerRange = rangeRequested hdrs
|
||||
-- According to the RFC (https://www.rfc-editor.org/rfc/rfc9110.html#name-range),
|
||||
-- the Range header must be ignored for all methods other than GET
|
||||
headerRange = if method == "GET" then rangeRequested hdrs else allRange
|
||||
limitRange = fromMaybe allRange (HM.lookup "limit" qsRanges)
|
||||
headerAndLimitRange = rangeIntersection headerRange limitRange
|
||||
-- Bypass all the ranges and send only the limit zero range (0 <= x <= -1) if
|
||||
|
||||
Reference in New Issue
Block a user