http-client 0.6.1 → 0.6.1.1
raw patch · 7 files changed
+22/−13 lines, 7 filesdep ~blaze-builderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: blaze-builder
API changes (from Hackage documentation)
- Network.HTTP.Client.Internal: readDec :: Integral i => String -> Maybe i
+ Network.HTTP.Client.Internal: readPositiveInt :: String -> Maybe Int
Files
- ChangeLog.md +4/−0
- Network/HTTP/Client.hs +1/−1
- Network/HTTP/Client/Request.hs +1/−1
- Network/HTTP/Client/Response.hs +1/−1
- Network/HTTP/Client/Util.hs +9/−9
- http-client.cabal +1/−1
- test-nonet/Network/HTTP/ClientSpec.hs +5/−0
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for http-client +## 0.6.1.1++* Ensure that `Int` parsing doesn't overflow [#383](https://github.com/snoyberg/http-client/issues/383)+ ## 0.6.1 * Add `setUriEither` to `Network.HTTP.Client.Internal`
Network/HTTP/Client.hs view
@@ -40,7 +40,7 @@ -- application which will make a large number of requests to different hosts, -- and will never make more than one connection to a single host, then sharing -- a 'Manager' will result in idle connections being kept open longer than--- necessary. In such a situation, it makes sense to use 'withManager' around+-- necessary. In such a situation, it makes sense to use 'newManager' before -- each new request, to avoid running out of file descriptors. (Note that the -- 'managerIdleConnectionCount' setting mitigates the risk of leaking too many -- file descriptors.)
Network/HTTP/Client/Request.hs view
@@ -263,7 +263,7 @@ ':':rest -> maybe (Left "Invalid port") return- (readDec rest)+ (readPositiveInt rest) -- Otherwise, use the default port _ -> case sec of False {- HTTP -} -> return 80
Network/HTTP/Client/Response.hs view
@@ -87,7 +87,7 @@ getResponse timeout' req@(Request {..}) mconn cont = do let conn = managedResource mconn StatusHeaders s version hs <- parseStatusHeaders conn timeout' cont- let mcl = lookup "content-length" hs >>= readDec . S8.unpack+ let mcl = lookup "content-length" hs >>= readPositiveInt . S8.unpack isChunked = ("transfer-encoding", CI.mk "chunked") `elem` map (second CI.mk) hs -- should we put this connection back into the connection manager?
Network/HTTP/Client/Util.hs view
@@ -1,15 +1,15 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} module Network.HTTP.Client.Util- ( readDec+ ( readPositiveInt ) where -import qualified Data.Text as T-import qualified Data.Text.Read+import Text.Read (readMaybe)+import Control.Monad (guard) -readDec :: Integral i => String -> Maybe i-readDec s =- case Data.Text.Read.decimal $ T.pack s of- Right (i, t)- | T.null t -> Just i- _ -> Nothing+-- | Read a positive 'Int', accounting for overflow+readPositiveInt :: String -> Maybe Int+readPositiveInt s = do+ i <- readMaybe s+ guard $ i >= 0+ Just i
http-client.cabal view
@@ -1,5 +1,5 @@ name: http-client-version: 0.6.1+version: 0.6.1.1 synopsis: An HTTP client engine description: Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/http-client>. homepage: https://github.com/snoyberg/http-client
test-nonet/Network/HTTP/ClientSpec.hs view
@@ -254,3 +254,8 @@ ok <- readIORef okRef unless ok $ throwIO (ErrorCall "already closed")++ it "does not allow port overflow #383" $ do+ case parseRequest "https://o_O:18446744072699450606" of+ Left _ -> pure () :: IO ()+ Right req -> error $ "Invalid request: " ++ show req