-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the possibility to set the maximum number of header fields #549
Changes from 9 commits
2812a6c
1411cf0
74d5048
4916257
c3312b4
d6644ac
b2e496a
a104b38
aa8930e
749ed45
1e82860
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
{-# LANGUAGE DeriveTraversable #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
module Network.HTTP.Client.Types | ||
( BodyReader | ||
, Connection (..) | ||
|
@@ -39,6 +40,9 @@ module Network.HTTP.Client.Types | |
, ResponseTimeout (..) | ||
, ProxySecureMode (..) | ||
, MaxHeaderLength (..) | ||
, noMaxHeaderLength | ||
, MaxNumberHeaders (..) | ||
, noMaxNumberHeaders | ||
) where | ||
|
||
import qualified Data.Typeable as T (Typeable) | ||
|
@@ -147,12 +151,14 @@ data HttpExceptionContent | |
-- | ||
-- @since 0.5.0 | ||
| OverlongHeaders | ||
-- ^ Either too many headers, or too many total bytes in a | ||
-- single header, were returned by the server, and the | ||
-- memory exhaustion protection in this library has kicked | ||
-- in. | ||
-- ^ Too many total bytes in a single header field were | ||
-- returned by the server. | ||
-- | ||
-- @since 0.5.0 | ||
| TooManyHeaders | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The introduction of this error might be considered a breaking change, but it also simplified debugging the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is acceptable, we've documented that adding extra constructors to error types is something end users should expect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I renamed it to |
||
-- ^ Too many header fields were returned by the server, | ||
-- | ||
-- @since 0.7.18 | ||
| ResponseTimeout | ||
-- ^ The server took too long to return a response. This can | ||
-- be altered via 'responseTimeout' or | ||
|
@@ -820,7 +826,18 @@ data ManagerSettings = ManagerSettings | |
-- Default: respect the @proxy@ value on the @Request@ itself. | ||
-- | ||
-- Since 0.4.7 | ||
, managerMaxHeaderLength :: Maybe MaxHeaderLength | ||
, managerMaxHeaderLength :: MaxHeaderLength | ||
-- ^ Configure the maximum size, in bytes, of an HTTP header field. | ||
-- | ||
-- Default: 4096 | ||
-- | ||
-- @since 0.7.17 | ||
, managerMaxNumberHeaders :: MaxNumberHeaders | ||
-- ^ Configure the maximum number of HTTP header fields. | ||
-- | ||
-- Default: 100 | ||
-- | ||
-- @since 0.7.18 | ||
} | ||
deriving T.Typeable | ||
|
||
|
@@ -845,9 +862,10 @@ data Manager = Manager | |
, mWrapException :: forall a. Request -> IO a -> IO a | ||
, mModifyRequest :: Request -> IO Request | ||
, mSetProxy :: Request -> Request | ||
, mModifyResponse :: Response BodyReader -> IO (Response BodyReader) | ||
, mModifyResponse :: Response BodyReader -> IO (Response BodyReader) | ||
-- ^ See 'managerProxy' | ||
, mMaxHeaderLength :: Maybe MaxHeaderLength | ||
, mMaxHeaderLength :: MaxHeaderLength | ||
, mMaxNumberHeaders :: MaxNumberHeaders | ||
} | ||
deriving T.Typeable | ||
|
||
|
@@ -906,4 +924,18 @@ data StreamFileStatus = StreamFileStatus | |
newtype MaxHeaderLength = MaxHeaderLength | ||
{ unMaxHeaderLength :: Int | ||
} | ||
deriving (Eq, Show) | ||
deriving (Eq, Show, Ord, Num, Enum, Bounded, T.Typeable) | ||
|
||
noMaxHeaderLength :: MaxHeaderLength | ||
noMaxHeaderLength = maxBound | ||
|
||
-- | The maximum number of header fields. | ||
-- | ||
-- @since 0.7.18 | ||
newtype MaxNumberHeaders = MaxNumberHeaders | ||
{ unMaxNumberHeaders :: Int | ||
} | ||
deriving (Eq, Show, Ord, Num, Enum, Bounded, T.Typeable) | ||
|
||
noMaxNumberHeaders :: MaxNumberHeaders | ||
noMaxNumberHeaders = maxBound |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also not change, yes it's an internal module, but there's no need to break end-user code for this.