packages feed

stompl 0.4.0 → 0.5.0

raw patch · 4 files changed

+18/−30 lines, 4 files

Files

Network/Mom/Stompl/Frame.hs view
@@ -1053,7 +1053,7 @@   getLen :: [Header] -> Either String Int   getLen hs =      case lookup hdrLen hs of-      Nothing -> Right (-1)+      Nothing -> Right (-1) -- -1 means no content-length header!       Just l  -> let len = cleanWhite l                  in if numeric len then Right $ read len                        else Left $ "content-length is not numeric: " ++ l
Network/Mom/Stompl/Parser.hs view
@@ -14,15 +14,14 @@ where    import           Data.Attoparsec.ByteString hiding (take, takeWhile, takeTill)-  import qualified Data.Attoparsec.ByteString as A   (takeWhile, takeTill)+  import qualified Data.Attoparsec.ByteString as A   import qualified Data.ByteString as B   import qualified Data.ByteString.UTF8 as U   import           Data.Word -   import           Control.Applicative ((<|>), (<$>))   import           Control.Monad (void)   import           Network.Mom.Stompl.Frame-+     ------------------------------------------------------------------------   -- | Parses a ByteString at once with Attoparsec 'parseOnly'.   --   May fail or conclude.@@ -194,28 +193,21 @@       _  -> fail $ "Expecting end-of-line: " ++ show c    -------------------------------------------------------------------------  -- read text until null or,-  -- if text length is given,-  -- until text length+  -- read text until end-of-body   ------------------------------------------------------------------------   body :: Int -> Parser B.ByteString-  body x = body' x B.empty-    where -      body' l i = do-        n <- A.takeTill (== nul)-        let b = i >|< n -        if l < 0 || l == B.length b-          then do-            _ <- word8 nul-            return b-          else -            if l < B.length b -              then failBodyLen l (B.length b)-              else do-                _ <- word8 nul-                body' l (b |> 0x00) +  body l | l == 0    = eob B.empty+         | l >  0    = A.take l >>= eob+         | otherwise = A.takeTill (== nul) >>= eob    ------------------------------------------------------------------------+  -- end-of-body: read nul and return the body +  ------------------------------------------------------------------------+  eob :: B.ByteString -> Parser B.ByteString+  eob b = do _ <- word8 nul+             return b++  ------------------------------------------------------------------------   -- escape header key and value;   -- we don't do this for connect and connected frames,   -- this is controlled by the Bool parameter.@@ -261,9 +253,3 @@   _c   =  99   _r   = 114   _n   = 110-  -  failBodyLen :: Int -> Int -> Parser a-  failBodyLen l1 l2 = -    fail $ "Body longer than indicated by content-length: " ++-           show l1 ++ " - " ++ show l2-  
changelog.md view
@@ -1,3 +1,5 @@+__0.5.0__ Much More efficient body parsing when length is given+ __0.4.0__ Bytestring instead of Bytestring.Char8  __0.3.0__ State Linkage Exception in license
stompl.cabal view
@@ -1,8 +1,8 @@ Name:            stompl Category:        Message-Oriented Middleware, Network, Stomp, Parser-Version:         0.4.0+Version:         0.5.0 Cabal-Version:   >= 1.8-Copyright:       Copyright (c) Tobias Schoofs, 2011 - 2015+Copyright:       Copyright (c) Tobias Schoofs, 2011 - 2016 License:         LGPL license-file:    license/lgpl-3.0ex.txt Author:          Tobias Schoofs