engine-io 1.1.2 → 1.2.0
raw patch · 3 files changed
+18/−7 lines, 3 filesdep ~textdep ~websocketsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: text, websockets
API changes (from Hackage documentation)
- Network.EngineIO: ServerAPI :: m (HashMap ByteString [ByteString]) -> (Int -> ByteString -> Builder -> forall a. m a) -> (forall a. Parser a -> m a) -> m ByteString -> (ServerApp -> m ()) -> ServerAPI m
+ Network.EngineIO: ServerAPI :: m (HashMap ByteString [ByteString]) -> (Int -> ByteString -> Builder -> forall a. m a) -> (forall a. Parser a -> m (Either String a)) -> m ByteString -> (ServerApp -> m ()) -> ServerAPI m
- Network.EngineIO: srvParseRequestBody :: ServerAPI m -> forall a. Parser a -> m a
+ Network.EngineIO: srvParseRequestBody :: ServerAPI m -> forall a. Parser a -> m (Either String a)
Files
- Changelog.md +6/−0
- engine-io.cabal +3/−3
- src/Network/EngineIO.hs +9/−4
Changelog.md view
@@ -1,3 +1,9 @@+## 1.2.0++* `ServerAPI`'s `srvParseParseRequestBody` has changed its return type to+ `Either String a`. This allows API providers to catch exceptions that may+ happen when attempting to perform this parse.+ ## 1.1.2 * 1.1.1 accidently removed `websockets` from the list of available upgrades.
engine-io.cabal view
@@ -1,5 +1,5 @@ name: engine-io-version: 1.1.2+version: 1.2.0 synopsis: A Haskell implementation of Engine.IO homepage: http://github.com/ocharles/engine.io license: BSD3@@ -37,11 +37,11 @@ monad-loops >=0.4 && <0.5, mwc-random >=0.13 && <0.14, stm >=2.4 && <2.5,- text >=0.11 && <1.2,+ text >=0.11 && <1.3, transformers >=0.2 && <0.5, unordered-containers >=0.2 && <0.3, vector >=0.10 && <0.11,- websockets >=0.8 && <0.9+ websockets >=0.8 && <0.10 hs-source-dirs: src default-language: Haskell2010
src/Network/EngineIO.hs view
@@ -331,7 +331,7 @@ -- should also terminate the web request entirely, such that further actions -- in @m@ have no effect. - , srvParseRequestBody :: forall a. Attoparsec.Parser a -> m a+ , srvParseRequestBody :: forall a. Attoparsec.Parser a -> m (Either String a) -- ^ Run a 'Attoparsec.Parser' against the request body. , srvGetRequestMethod :: m BS.ByteString@@ -340,7 +340,6 @@ , srvRunWebSocket :: WebSockets.ServerApp -> m () -- ^ Upgrade the current connection to run a WebSocket action.- } @@ -616,8 +615,14 @@ writeBytes api (encodePayload supportsBinary (Payload (V.fromList packets))) post = do- Payload packets <- srvParseRequestBody parsePayload- liftIO $ STM.atomically (V.mapM_ (STM.writeTChan (transIn transport)) packets)+ p <- srvParseRequestBody parsePayload+ case p of+ Left ex -> do+ liftIO $ putStrLn $ "WARNING: Parse failure in Network.EngineIO.handlePoll: " ++ show ex+ srvTerminateWithResponse 400 "text/plain" "Empty request body"++ Right (Payload packets) ->+ liftIO $ STM.atomically (V.mapM_ (STM.writeTChan (transIn transport)) packets) --------------------------------------------------------------------------------