diff --git a/http-client/Network/HTTP/Client.hs b/http-client/Network/HTTP/Client.hs index 4182ee58..d5cd9fe9 100644 --- a/http-client/Network/HTTP/Client.hs +++ b/http-client/Network/HTTP/Client.hs @@ -323,12 +323,12 @@ managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings managerSetProxy po = managerSetInsecureProxy po . managerSetSecureProxy po -- @since 0.7.17 -managerSetMaxHeaderLength :: Word -> ManagerSettings -> ManagerSettings +managerSetMaxHeaderLength :: Int -> ManagerSettings -> ManagerSettings managerSetMaxHeaderLength l manager = manager { managerMaxHeaderLength = MaxHeaderLength l } -- @since 0.7.18 -managerSetMaxNumberHeaders :: Word -> ManagerSettings -> ManagerSettings +managerSetMaxNumberHeaders :: Int -> ManagerSettings -> ManagerSettings managerSetMaxNumberHeaders n manager = manager { managerMaxNumberHeaders = MaxNumberHeaders n } diff --git a/http-client/Network/HTTP/Client/Connection.hs b/http-client/Network/HTTP/Client/Connection.hs index 673b0d61..26db9638 100644 --- a/http-client/Network/HTTP/Client/Connection.hs +++ b/http-client/Network/HTTP/Client/Connection.hs @@ -50,7 +50,7 @@ connectionReadLineWith mhl conn bs0 = go bs front total = case S.break (== charLF) bs of (_, "") -> do - let total' = total + fromIntegral (S.length bs) + let total' = total + S.length bs when (total > unMaxHeaderLength mhl) $ do -- We reached the maximum length for an header field. throwHttp OverlongHeaders diff --git a/http-client/Network/HTTP/Client/Headers.hs b/http-client/Network/HTTP/Client/Headers.hs index 7b585838..d1ba2bfe 100644 --- a/http-client/Network/HTTP/Client/Headers.hs +++ b/http-client/Network/HTTP/Client/Headers.hs @@ -91,13 +91,13 @@ parseStatusHeaders mhl mnh conn timeout' onEarlyHintHeaders cont Just (i, "") -> Just i _ -> Nothing - guardMaxNumberHeaders :: Word -> IO () + guardMaxNumberHeaders :: Int -> IO () guardMaxNumberHeaders count = when (count >= unMaxNumberHeaders mnh) $ do -- We reached the maximum number of header fields. throwHttp TooManyHeaders - parseHeaders :: Word -> ([Header] -> [Header]) -> IO [Header] + parseHeaders :: Int -> ([Header] -> [Header]) -> IO [Header] parseHeaders count front = do guardMaxNumberHeaders count line <- connectionReadLine mhl conn @@ -112,7 +112,7 @@ parseStatusHeaders mhl mnh conn timeout' onEarlyHintHeaders cont -- an exception, ignore it for robustness. parseHeaders count front - parseEarlyHintHeadersUntilFailure :: Word -> ([Header] -> [Header]) -> IO [Header] + parseEarlyHintHeadersUntilFailure :: Int -> ([Header] -> [Header]) -> IO [Header] parseEarlyHintHeadersUntilFailure count front = do guardMaxNumberHeaders count line <- connectionReadLine mhl conn diff --git a/http-client/Network/HTTP/Client/Types.hs b/http-client/Network/HTTP/Client/Types.hs index 8473bf9e..3fb1d020 100644 --- a/http-client/Network/HTTP/Client/Types.hs +++ b/http-client/Network/HTTP/Client/Types.hs @@ -922,7 +922,7 @@ data StreamFileStatus = StreamFileStatus -- -- @since 0.7.14 newtype MaxHeaderLength = MaxHeaderLength - { unMaxHeaderLength :: Word + { unMaxHeaderLength :: Int } deriving (Eq, Show, Ord, Num, Enum, Bounded, T.Typeable) @@ -933,7 +933,7 @@ noMaxHeaderLength = maxBound -- -- @since 0.7.18 newtype MaxNumberHeaders = MaxNumberHeaders - { unMaxNumberHeaders :: Word + { unMaxNumberHeaders :: Int } deriving (Eq, Show, Ord, Num, Enum, Bounded, T.Typeable)