on master help sign in
Merge pull request #388 from yesodweb/internal-apis

Internal apis

commit8310a2211ebb190bd23de9dee8c4a2c6c1c244a7 authorMichael Snoyman <michael@snoyman.com> dateThu 18 Jun 2015, 13:31 (11 years ago) parent82109e01c4db35
4 files changed+73−19
warp/Network/Wai/Handler/Warp.hs+12−10 warp/Network/Wai/Handler/Warp/Internal.hs+57−8 warp/Network/Wai/Handler/Warp/Settings.hs+1−1 warp/Network/Wai/Handler/Warp/Timeout.hs+3
warp/Network/Wai/Handler/Warp.hs+12−10
@@ -39,10 +39,6 @@ module Network.Wai.Handler.Warp (
3939 , runEnv
4040 , runSettings
4141 , runSettingsSocket
42− -- ** Low level run functions
43− , runSettingsConnection
44− , runSettingsConnectionMaker
45− , runSettingsConnectionMakerSecure
4642 -- * Settings
4743 , Settings
4844 , defaultSettings
@@ -88,10 +84,19 @@ module Network.Wai.Handler.Warp (
8884 , defaultOnExceptionResponse
8985 , exceptionResponseForDebug
9086 -- * Data types
91− , Transport (..)
9287 , HostPreference (..)
9388 , Port
9489 , InvalidRequest (..)
90+ -- * Per-request utilities
91+ , pauseTimeout
92+ -- * Internal
93+ -- | The following APIs will move to Network.Wai.Handler.Warp.Internal.
94+
95+ -- ** Low level run functions
96+ , runSettingsConnection
97+ , runSettingsConnectionMaker
98+ , runSettingsConnectionMakerSecure
99+ , Transport (..)
95100 -- * Connection
96101 , Connection (..)
97102 , socketConnection
@@ -106,9 +111,6 @@ module Network.Wai.Handler.Warp (
106111 , SendFile
107112 , sendFile
108113 , readSendFile
109− -- * Per-request utilities
110− , pauseTimeout
111− -- * Internal
112114 -- ** Version
113115 , warpVersion
114116 -- ** Data types
@@ -150,7 +152,7 @@ import Network.Wai.Handler.Warp.Types
150152-- | Port to listen on. Default value: 3000
151153--
152154-- Since 2.1.0
153−setPort :: Int -> Settings -> Settings
155+setPort :: Port -> Settings -> Settings
154156setPort x y = y { settingsPort = x }
155157
156158-- | Interface to bind to. Default value: HostIPv4
@@ -238,7 +240,7 @@ setNoParsePath x y = y { settingsNoParsePath = x }
238240-- | Get the listening port.
239241--
240242-- Since 2.1.1
241−getPort :: Settings -> Int
243+getPort :: Settings -> Port
242244getPort = settingsPort
243245
244246-- | Get the interface to bind to.
warp/Network/Wai/Handler/Warp/Internal.hs+57−8
@@ -1,15 +1,64 @@
11{-# OPTIONS_GHC -fno-warn-deprecations #-}
2−module Network.Wai.Handler.Warp.Internal
3− ( Settings (..)
4− , getOnOpen
5− , getOnClose
6− , getOnException
7− ) where
82
9−import Network.Wai.Handler.Warp.Settings (Settings (..))
3+module Network.Wai.Handler.Warp.Internal (
4+ -- * Settings
5+ Settings (..)
6+ -- ** Getters
7+ , getOnOpen
8+ , getOnClose
9+ , getOnException
10+ -- * Low level run functions
11+ , runSettingsConnection
12+ , runSettingsConnectionMaker
13+ , runSettingsConnectionMakerSecure
14+ , Transport (..)
15+ -- * Connection
16+ , Connection (..)
17+ , socketConnection
18+ -- ** Buffer
19+ , Buffer
20+ , BufSize
21+ , bufferSize
22+ , allocateBuffer
23+ , freeBuffer
24+ -- ** Sendfile
25+ , FileId (..)
26+ , SendFile
27+ , sendFile
28+ , readSendFile
29+ -- * Version
30+ , warpVersion
31+ -- * Data types
32+ , InternalInfo (..)
33+ , HeaderValue
34+ , IndexedHeader
35+ , requestMaxIndex
36+ -- * Time out manager
37+ , module Network.Wai.Handler.Warp.Timeout
38+ -- * File descriptor cache
39+ , module Network.Wai.Handler.Warp.FdCache
40+ -- * Date
41+ , module Network.Wai.Handler.Warp.Date
42+ -- * Request and response
43+ , Source
44+ , recvRequest
45+ , sendResponse
46+ ) where
47+
48+import Control.Exception (SomeException)
1049import Network.Socket (SockAddr)
1150import Network.Wai (Request)
12−import Control.Exception (SomeException)
51+import Network.Wai.Handler.Warp.Buffer
52+import Network.Wai.Handler.Warp.Date
53+import Network.Wai.Handler.Warp.FdCache
54+import Network.Wai.Handler.Warp.Header
55+import Network.Wai.Handler.Warp.Request
56+import Network.Wai.Handler.Warp.Response
57+import Network.Wai.Handler.Warp.Run
58+import Network.Wai.Handler.Warp.SendFile
59+import Network.Wai.Handler.Warp.Settings
60+import Network.Wai.Handler.Warp.Timeout
61+import Network.Wai.Handler.Warp.Types
1362
1463getOnOpen :: Settings -> SockAddr -> IO Bool
1564getOnOpen = settingsOnOpen
warp/Network/Wai/Handler/Warp/Settings.hs+1−1
@@ -32,7 +32,7 @@ import qualified Paths_warp
3232--
3333-- > setTimeout 20 defaultSettings
3434data Settings = Settings
35− { settingsPort :: Int -- ^ Port to listen on. Default value: 3000
35+ { settingsPort :: Port -- ^ Port to listen on. Default value: 3000
3636 , settingsHost :: HostPreference -- ^ Default value: HostIPv4
3737 , settingsOnException :: Maybe Request -> SomeException -> IO () -- ^ What to do with exceptions thrown by either the application or server. Default: ignore server-generated exceptions (see 'InvalidRequest') and print application-generated applications to stderr.
3838 , settingsOnExceptionResponse :: SomeException -> Response
warp/Network/Wai/Handler/Warp/Timeout.hs+3
@@ -5,6 +5,9 @@
55
66-- |
77--
8+-- Note that this module will not be exported in the near future.
9+-- Please use Network.Wai.Handler.Warp.Internal instead.
10+--
811-- In order to provide slowloris protection, Warp provides timeout handlers. We
912-- follow these rules:
1013--