Skip to content

Commit 618c475

Browse files
committed
providing defaultConfig
1 parent 1a21377 commit 618c475

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

Network/.DS_Store

6 KB
Binary file not shown.

Network/HTTP2/Client.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,17 @@ module Network.HTTP2.Client (
7171
rstRateLimit,
7272

7373
-- * Common configuration
74-
Config (..),
74+
Config,
75+
defaultConfig,
76+
confWriteBuffer,
77+
confBufferSize,
78+
confSendAll,
79+
confReadN,
80+
confPositionReadMaker,
81+
confTimeoutManager,
82+
confMySockAddr,
83+
confPeerSockAddr,
84+
confReadNTimeout,
7585
allocSimpleConfig,
7686
allocSimpleConfig',
7787
freeSimpleConfig,

Network/HTTP2/Client/Internal.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Network.HTTP2.Client.Internal (
22
Request (..),
33
Response (..),
4+
Config (..),
45
ClientConfig (..),
56
Settings (..),
67
Aux (..),

Network/HTTP2/H2/Types.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Control.Exception (
1414
)
1515
import qualified Control.Exception as E
1616
import Data.IORef
17+
import Foreign.Ptr (nullPtr)
1718
import Network.Control
1819
import Network.HTTP.Semantics.Client
1920
import Network.HTTP.Semantics.IO
@@ -272,6 +273,22 @@ data Config = Config
272273
, confReadNTimeout :: Bool
273274
}
274275

276+
-- | Default config. This is just a template to modify via
277+
-- field names. Don't use this without modifications.
278+
defaultConfig :: Config
279+
defaultConfig =
280+
Config
281+
{ confWriteBuffer = nullPtr
282+
, confBufferSize = 0
283+
, confSendAll = \_ -> return ()
284+
, confReadN = \_ -> return ""
285+
, confPositionReadMaker = defaultPositionReadMaker
286+
, confTimeoutManager = T.defaultManager
287+
, confMySockAddr = SockAddrInet 0 0
288+
, confPeerSockAddr = SockAddrInet 0 0
289+
, confReadNTimeout = False
290+
}
291+
275292
isAsyncException :: Exception e => e -> Bool
276293
isAsyncException e =
277294
case E.fromException (E.toException e) of

Network/HTTP2/Server.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,17 @@ module Network.HTTP2.Server (
5151
rstRateLimit,
5252

5353
-- * Common configuration
54-
Config (..),
54+
Config,
55+
defaultConfig,
56+
confWriteBuffer,
57+
confBufferSize,
58+
confSendAll,
59+
confReadN,
60+
confPositionReadMaker,
61+
confTimeoutManager,
62+
confMySockAddr,
63+
confPeerSockAddr,
64+
confReadNTimeout,
5565
allocSimpleConfig,
5666
allocSimpleConfig',
5767
freeSimpleConfig,

Network/HTTP2/Server/Internal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module Network.HTTP2.Server.Internal (
22
Request (..),
33
Response (..),
4+
Config (..),
5+
ServerConfig (..),
46
Aux (..),
57

68
-- * Low level

0 commit comments

Comments
 (0)