on master help sign in
fix the websockets interceptor, stop processing when due
commitbd63158ca53a6dec6b04316800236aa6c521b907 authorFrancesco <f@mazzo.li> dateFri 11 May 2012, 12:05 (14 years ago) parent8149617
1 file changed+8−1
wai-websockets/Network/Wai/Handler/WebSockets.hs+8−1
wai-websockets/Network/Wai/Handler/WebSockets.hs+8−1
@@ -52,7 +52,10 @@ runWebSockets opts req app source conn = do
5252
5353 push iter bs = do
5454 step <- liftIO $ E.runIteratee $ E.enumList 1 [bs] E.$$ iter
55− return $ C.StateProcessing $ E.returnI step
55+ case step of
56+ E.Continue _ -> return $ C.StateProcessing $ E.returnI step
57+ E.Yield out inp -> return $ C.StateDone (streamToMaybe inp) out
58+ E.Error e -> C.monadThrow e
5659 close iter = do
5760 _ <- liftIO $ E.runIteratee $ E.enumEOF E.$$ iter
5861 return ()
@@ -63,3 +66,7 @@ iterConnection c = E.continue go
6366 go (E.Chunks []) = E.continue go
6467 go (E.Chunks cs) = E.tryIO (Warp.connSendMany c cs) >> E.continue go
6568 go E.EOF = E.continue go
69+
70+streamToMaybe :: E.Stream S.ByteString -> Maybe S.ByteString
71+streamToMaybe E.EOF = Nothing
72+streamToMaybe (E.Chunks bs) = Just $ S.concat bs