Add comment about what the bug was. Make ReqBodyState strict.

This commit is contained in:
Julian K. Arni 2015-01-03 18:16:26 +01:00
parent ecb1da0e37
commit 726848b8a3

View file

@ -27,12 +27,15 @@ import Servant.API
import Servant.Common.Text import Servant.Common.Text
data ReqBodyState = Uncalled data ReqBodyState = Uncalled
| Called B.ByteString | Called !B.ByteString
| Done B.ByteString | Done !B.ByteString
toApplication :: RoutingApplication -> Application toApplication :: RoutingApplication -> Application
toApplication ra request respond = do toApplication ra request respond = do
reqBodyRef <- newIORef Uncalled 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 let memoReqBody = do
ior <- readIORef reqBodyRef ior <- readIORef reqBodyRef
case ior of case ior of