on master help sign in
Force some evaluation in wai-test
commit52b2238dc7b4ccaf472e401fa032066301647736 authorMichael Snoyman <michael@snoyman.com> dateThu 22 May 2014, 20:24 (12 years ago) parent059a145
1 file changed+5−1
wai-extra/Network/Wai/Test.hs+5−1
wai-extra/Network/Wai/Test.hs+5−1
@@ -116,7 +116,11 @@ runResponse ref res = do
116116 let add y = atomicModifyIORef refBuilder $ \x -> (x `mappend` y, ())
117117 withBody $ \body -> body add (return ())
118118 builder <- readIORef refBuilder
119− writeIORef ref $ SResponse s h $ toLazyByteString builder
119+ let lbs = toLazyByteString builder
120+ len = L.length lbs
121+ -- Force evaluation of the body to have exceptions thrown at the right
122+ -- time.
123+ seq len $ writeIORef ref $ SResponse s h $ toLazyByteString builder
120124 return ResponseReceived
121125 where
122126 (s, h, withBody) = responseToStream res