From 726848b8a3e58bc92172bc1bedd7e9d72d2b9b8c Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Sat, 3 Jan 2015 18:16:26 +0100 Subject: [PATCH] Add comment about what the bug was. Make ReqBodyState strict. --- src/Servant/Server/Internal.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Servant/Server/Internal.hs b/src/Servant/Server/Internal.hs index 2b16fea0..5a9fbe5b 100644 --- a/src/Servant/Server/Internal.hs +++ b/src/Servant/Server/Internal.hs @@ -27,12 +27,15 @@ import Servant.API import Servant.Common.Text data ReqBodyState = Uncalled - | Called B.ByteString - | Done B.ByteString + | Called !B.ByteString + | Done !B.ByteString toApplication :: RoutingApplication -> Application toApplication ra request respond = do reqBodyRef <- newIORef Uncalled + -- We need to check the requestBody possibly more than once, so instead + -- of consuming it entirely once, we cycle through it. + -- See https://github.com/haskell-servant/servant/issues/3 let memoReqBody = do ior <- readIORef reqBodyRef case ior of