http-kit 0.2.2 → 0.3.0
raw patch · 2 files changed
+9/−11 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- http-kit.cabal +1/−1
- src/Network/HTTP/Toolkit/Header.hs +8/−10
http-kit.cabal view
@@ -1,5 +1,5 @@ name: http-kit-version: 0.2.2+version: 0.3.0 synopsis: A low-level HTTP library description: A low-level HTTP library that can be used to build more sophisticated applications on top of it.
src/Network/HTTP/Toolkit/Header.hs view
@@ -83,28 +83,26 @@ readHeaderLines n c = go n where go limit = do- (newLimit, bs) <- readLine c limit- if B.null bs then return [] else (bs :) <$> go newLimit+ bs <- readHeaderLine c limit+ if B.null bs then return [] else (bs :) <$> go (limit - B.length bs) -- | The default message header size limit of 65536 bytes (64 KB). defaultHeaderSizeLimit :: Limit defaultHeaderSizeLimit = 64 * 1024 -readLine :: Connection -> Limit -> IO (Limit, ByteString)-readLine c = fmap (\(n, xs) -> (n, stripCR xs)) . go+readHeaderLine :: Connection -> Limit -> IO ByteString+readHeaderLine c = fmap stripCR . go where go limit = do+ when (limit < 0) (throwIO HeaderTooLarge) bs <- connectionRead c- let n = B.length bs- newLimit = limit - n- when (newLimit < 0) (throwIO HeaderTooLarge) case B.break (== '\n') bs of (xs, "") -> do- (ll, ys) <- go newLimit- return (ll, xs `B.append` ys)+ ys <- go (limit - B.length xs)+ return (xs `B.append` ys) (xs, ys) -> do connectionUnread c (B.drop 1 ys)- return (newLimit, xs)+ return xs stripCR bs | (not . B.null) bs && B.last bs == '\r' = B.init bs | otherwise = bs