git.iko.soy/typeable/servant
on master help sign in
Add comment about what the bug was. Make ReqBodyState strict.
726848bJulian K. Arni
src/Servant/Server/Internal.hs+5−2
@@ -27,12 +27,15 @@ import Servant.API
27import Servant.Common.Text
27import Servant.Common.Text
28
28
29data ReqBodyState = Uncalled
29data ReqBodyState = Uncalled
30− | Called B.ByteString
30+ | Called !B.ByteString
31− | Done B.ByteString
31+ | Done !B.ByteString
32
32
33toApplication :: RoutingApplication -> Application
33toApplication :: RoutingApplication -> Application
34toApplication ra request respond = do
34toApplication ra request respond = do
35 reqBodyRef <- newIORef Uncalled
35 reqBodyRef <- newIORef Uncalled
36+ -- We need to check the requestBody possibly more than once, so instead
37+ -- of consuming it entirely once, we cycle through it.
38+ -- See https://github.com/haskell-servant/servant/issues/3
36 let memoReqBody = do
39 let memoReqBody = do
37 ior <- readIORef reqBodyRef
40 ior <- readIORef reqBodyRef
38 case ior of
41 case ior of