Add comment about what the bug was. Make ReqBodyState strict.
This commit is contained in:
parent
ecb1da0e37
commit
726848b8a3
1 changed files with 5 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue