Skip to content

Commit

Permalink
Switch back to Int
Browse files Browse the repository at this point in the history
  • Loading branch information
marinelli committed Dec 16, 2024
1 parent b2e496a commit a104b38
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions http-client/Network/HTTP/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion http-client/Network/HTTP/Client/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions http-client/Network/HTTP/Client/Headers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions http-client/Network/HTTP/Client/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit a104b38

Please sign in to comment.