on master help sign in
doc update.
commit8008501f485b218873389b58f6dada1ab6bc242d authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 30 Oct 2013, 10:32 (13 years ago) parent63025b5
4 files changed+19−1
warp/Network/Wai/Handler/Warp.hs+1 warp/Network/Wai/Handler/Warp/FdCache.hs+7 warp/Network/Wai/Handler/Warp/Header.hs+6 warp/Network/Wai/Handler/Warp/Types.hs+5−1
warp/Network/Wai/Handler/Warp.hs+1
@@ -53,6 +53,7 @@ module Network.Wai.Handler.Warp (
5353 , HeaderValue
5454 , IndexedHeader
5555 , defaultIndexRequestHeader
56+ , requestMaxIndex
5657 -- ** Time out manager
5758 , module Network.Wai.Handler.Warp.Timeout
5859 -- ** File descriptor cache
warp/Network/Wai/Handler/Warp/FdCache.hs+7
@@ -38,6 +38,7 @@ data Status = Active | Inactive
3838
3939newtype MutableStatus = MutableStatus (IORef Status)
4040
41+-- | An action to activate a Fd cache entry.
4142type Refresh = IO ()
4243
4344status :: MutableStatus -> IO Status
@@ -65,6 +66,8 @@ newFdEntry path = FdEntry path
6566
6667type Hash = Int
6768type FdCache = MMap Hash FdEntry
69+
70+-- | Mutable Fd cacher.
6871newtype MutableFdCache = MutableFdCache (IORef FdCache)
6972
7073fdCache :: MutableFdCache -> IO FdCache
@@ -93,6 +96,8 @@ look mfc path key = searchWith key check <$> fdCache mfc
9396
9497----------------------------------------------------------------
9598
99+-- | Creating 'MutableFdCache' and executing the action in the second
100+-- argument. The first argument is a cache duration in second.
96101withFdCache :: Int -> (Maybe MutableFdCache -> IO a) -> IO a
97102withFdCache duration action = bracket (initialize duration)
98103 terminate
@@ -100,6 +105,7 @@ withFdCache duration action = bracket (initialize duration)
100105
101106----------------------------------------------------------------
102107
108+-- The first argument is a cache duration in second.
103109initialize :: Int -> IO (Maybe MutableFdCache)
104110initialize 0 = return Nothing
105111initialize duration = do
@@ -142,6 +148,7 @@ terminate (Just (MutableFdCache ref)) = mask_ $ do
142148
143149----------------------------------------------------------------
144150
151+-- | Getting 'Fd' and 'Refresh' from the mutable Fd cacher.
145152getFd :: MutableFdCache -> FilePath -> IO (Fd, Refresh)
146153getFd mfc path = look mfc path key >>= getFd'
147154 where
warp/Network/Wai/Handler/Warp/Header.hs+6
@@ -9,6 +9,7 @@ import Network.Wai.Handler.Warp.Types
99
1010----------------------------------------------------------------
1111
12+-- | Array for a set of HTTP headers.
1213type IndexedHeader = Array Int (Maybe HeaderValue)
1314
1415----------------------------------------------------------------
@@ -25,9 +26,14 @@ idxConnection = 3
2526idxRange = 4
2627idxHost = 5
2728
29+-- | The size for 'IndexedHeader' for HTTP Request.
2830requestMaxIndex :: Int
2931requestMaxIndex = 5
3032
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\".
3137defaultIndexRequestHeader :: IndexedHeader
3238defaultIndexRequestHeader = array (0,requestMaxIndex) [(i,Nothing)|i<-[0..requestMaxIndex]]
3339
warp/Network/Wai/Handler/Warp/Types.hs+5−1
@@ -51,7 +51,11 @@ instance Exception InvalidRequest
5151
5252----------------------------------------------------------------
5353
54−data ConnSendFileOverride = NotOverride | Override Socket
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.
57+data ConnSendFileOverride = NotOverride -- ^ Don't override
58+ | Override Socket -- ^ Override with this 'Socket'
5559
5660----------------------------------------------------------------
5761