From 5c48ec11eea5891287f97d7d660fe1c762f624a5 Mon Sep 17 00:00:00 2001 From: Marco Zocca Date: Wed, 27 Sep 2023 21:15:35 +0200 Subject: [PATCH 1/2] add comments and remove unused RequestBodyState --- Web/Scotty/Internal/Types.hs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Web/Scotty/Internal/Types.hs b/Web/Scotty/Internal/Types.hs index 8bfd8023..76a7723b 100644 --- a/Web/Scotty/Internal/Types.hs +++ b/Web/Scotty/Internal/Types.hs @@ -72,12 +72,15 @@ type Application m = Request -> m Response ------------------ Scotty Request Body -------------------- -data BodyChunkBuffer = BodyChunkBuffer { hasFinishedReadingChunks :: Bool - , chunksReadSoFar :: [BS.ByteString] } - -data BodyInfo = BodyInfo { bodyInfoReadProgress :: MVar Int +data BodyChunkBuffer = BodyChunkBuffer { hasFinishedReadingChunks :: Bool -- ^ whether we've reached the end of the stream yet + , chunksReadSoFar :: [BS.ByteString] + } +-- | The key part of having two MVars is that we can "clone" the BodyInfo to create a copy where the index is reset to 0, but the chunk cache is the same. Passing a cloned BodyInfo into each matched route allows them each to start from the first chunk if they call bodyReader. +-- +-- Introduced in (#308) +data BodyInfo = BodyInfo { bodyInfoReadProgress :: MVar Int -- ^ index into the stream read so far , bodyInfoChunkBuffer :: MVar BodyChunkBuffer - , bodyInfoDirectChunkRead :: IO BS.ByteString + , bodyInfoDirectChunkRead :: IO BS.ByteString -- ^ can be called to get more chunks } --------------- Scotty Applications ----------------- @@ -154,10 +157,6 @@ data ActionEnv = Env { getReq :: Request , getFiles :: [File] } -data RequestBodyState = BodyUntouched - | BodyCached LBS8.ByteString [BS.ByteString] -- whole body, chunks left to stream - | BodyCorrupted - data BodyPartiallyStreamed = BodyPartiallyStreamed deriving (Show, Typeable) instance E.Exception BodyPartiallyStreamed From 5d6494c5cf3dcf35da0e2d0c80024397c0540056 Mon Sep 17 00:00:00 2001 From: Marco Zocca Date: Wed, 27 Sep 2023 21:17:40 +0200 Subject: [PATCH 2/2] changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 23a5c719..0f6ffa0a 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ * Disambiguate request parameters (#204). Adjust the `Env` type to have three [Param] fields instead of one, add `captureParam`, `formParam`, `queryParam` and the associated `captureParams`, `formParams`, `queryParams`. Add deprecation notices to `param` and `params`. * Add `Scotty.Cookie` module. * Change body parsing behaviour such that calls to 'next' don't result in POST request bodies disappearing (#147). +* (Internal) Remove unused type RequestBodyState (#313) ## 0.12.1 [2022.11.17] * Fix CPP bug that prevented tests from building on Windows.