on master help sign in
doc update.
8008501Kazu Yamamoto
warp/Network/Wai/Handler/Warp.hs+1
@@ -53,6 +53,7 @@ module Network.Wai.Handler.Warp (
53 , HeaderValue
53 , HeaderValue
54 , IndexedHeader
54 , IndexedHeader
55 , defaultIndexRequestHeader
55 , defaultIndexRequestHeader
56+ , requestMaxIndex
56 -- ** Time out manager
57 -- ** Time out manager
57 , module Network.Wai.Handler.Warp.Timeout
58 , module Network.Wai.Handler.Warp.Timeout
58 -- ** File descriptor cache
59 -- ** File descriptor cache
warp/Network/Wai/Handler/Warp/FdCache.hs+7
@@ -38,6 +38,7 @@ data Status = Active | Inactive
38
38
39newtype MutableStatus = MutableStatus (IORef Status)
39newtype MutableStatus = MutableStatus (IORef Status)
40
40
41+-- | An action to activate a Fd cache entry.
41type Refresh = IO ()
42type Refresh = IO ()
42
43
43status :: MutableStatus -> IO Status
44status :: MutableStatus -> IO Status
@@ -65,6 +66,8 @@ newFdEntry path = FdEntry path
65
66
66type Hash = Int
67type Hash = Int
67type FdCache = MMap Hash FdEntry
68type FdCache = MMap Hash FdEntry
69+
70+-- | Mutable Fd cacher.
68newtype MutableFdCache = MutableFdCache (IORef FdCache)
71newtype MutableFdCache = MutableFdCache (IORef FdCache)
69
72
70fdCache :: MutableFdCache -> IO FdCache
73fdCache :: MutableFdCache -> IO FdCache
@@ -93,6 +96,8 @@ look mfc path key = searchWith key check <$> fdCache mfc
93
96
94----------------------------------------------------------------
97----------------------------------------------------------------
95
98
99+-- | Creating 'MutableFdCache' and executing the action in the second
100+-- argument. The first argument is a cache duration in second.
96withFdCache :: Int -> (Maybe MutableFdCache -> IO a) -> IO a
101withFdCache :: Int -> (Maybe MutableFdCache -> IO a) -> IO a
97withFdCache duration action = bracket (initialize duration)
102withFdCache duration action = bracket (initialize duration)
98 terminate
103 terminate
@@ -100,6 +105,7 @@ withFdCache duration action = bracket (initialize duration)
100
105
101----------------------------------------------------------------
106----------------------------------------------------------------
102
107
108+-- The first argument is a cache duration in second.
103initialize :: Int -> IO (Maybe MutableFdCache)
109initialize :: Int -> IO (Maybe MutableFdCache)
104initialize 0 = return Nothing
110initialize 0 = return Nothing
105initialize duration = do
111initialize duration = do
@@ -142,6 +148,7 @@ terminate (Just (MutableFdCache ref)) = mask_ $ do
142
148
143----------------------------------------------------------------
149----------------------------------------------------------------
144
150
151+-- | Getting 'Fd' and 'Refresh' from the mutable Fd cacher.
145getFd :: MutableFdCache -> FilePath -> IO (Fd, Refresh)
152getFd :: MutableFdCache -> FilePath -> IO (Fd, Refresh)
146getFd mfc path = look mfc path key >>= getFd'
153getFd mfc path = look mfc path key >>= getFd'
147 where
154 where
warp/Network/Wai/Handler/Warp/Header.hs+6
@@ -9,6 +9,7 @@ import Network.Wai.Handler.Warp.Types
9
9
10----------------------------------------------------------------
10----------------------------------------------------------------
11
11
12+-- | Array for a set of HTTP headers.
12type IndexedHeader = Array Int (Maybe HeaderValue)
13type IndexedHeader = Array Int (Maybe HeaderValue)
13
14
14----------------------------------------------------------------
15----------------------------------------------------------------
@@ -25,9 +26,14 @@ idxConnection = 3
25idxRange = 4
26idxRange = 4
26idxHost = 5
27idxHost = 5
27
28
29+-- | The size for 'IndexedHeader' for HTTP Request.
28requestMaxIndex :: Int
30requestMaxIndex :: Int
29requestMaxIndex = 5
31requestMaxIndex = 5
30
32
33+-- | Default 'IndexedHeader' for HTTP Request.
34+-- All valuers are 'Nothing' by default.
35+-- They correspond to \"Content-Length\", \"Transfer-Encoding\",
36+-- \"Expect\", \"Connection\", \"Range\", and \"Host\".
31defaultIndexRequestHeader :: IndexedHeader
37defaultIndexRequestHeader :: IndexedHeader
32defaultIndexRequestHeader = array (0,requestMaxIndex) [(i,Nothing)|i<-[0..requestMaxIndex]]
38defaultIndexRequestHeader = array (0,requestMaxIndex) [(i,Nothing)|i<-[0..requestMaxIndex]]
33
39
warp/Network/Wai/Handler/Warp/Types.hs+5−1
@@ -51,7 +51,11 @@ instance Exception InvalidRequest
51
51
52----------------------------------------------------------------
52----------------------------------------------------------------
53
53
54+-- | Whether or not 'ConnSendFileOverride' in 'Connection' can be
55+-- overridden. This is a kind of hack to keep the signature of
56+-- 'Connection' clean.
54−data ConnSendFileOverride = NotOverride | Override Socket
57+data ConnSendFileOverride = NotOverride -- ^ Don't override
58+ | Override Socket -- ^ Override with this 'Socket'
55
59
56----------------------------------------------------------------
60----------------------------------------------------------------
57
61