@@ -144,14 +144,14 @@ sendResponse settings conn ii req reqidxhdr src response = do
144 -- and status, the response to HEAD is processed here.
144 -- and status, the response to HEAD is processed here.
146 -- See definition of rsp below for proper body stripping.
146 -- See definition of rsp below for proper body stripping.
147− (ms, mlen) <- sendRsp conn ii req ver s hs rsp
147+ (ms, mlen) <- sendRsp conn ii ver s hs rsp
148 case ms of
148 case ms of
149 Nothing -> return ()
149 Nothing -> return ()
150 Just realStatus -> logger req realStatus mlen
150 Just realStatus -> logger req realStatus mlen
151 T.tickle th
151 T.tickle th
152 return ret
152 return ret
154− _ <- sendRsp conn ii req ver s hs RspNoBody
154+ _ <- sendRsp conn ii ver s hs RspNoBody
155 logger req s Nothing
155 logger req s Nothing
156 T.tickle th
156 T.tickle th
157 return isPersist
157 return isPersist
@@ -221,7 +221,6 @@ data Rsp = RspNoBody
222sendRsp :: Connection
222sendRsp :: Connection
223 -> InternalInfo
223 -> InternalInfo
225 -> H.HttpVersion
224 -> H.HttpVersion
226 -> H.Status
225 -> H.Status
227 -> H.ResponseHeaders
226 -> H.ResponseHeaders
@@ -230,7 +229,7 @@ sendRsp :: Connection
231----------------------------------------------------------------
230----------------------------------------------------------------
233−sendRsp conn _ _ ver s hs RspNoBody = do
232+sendRsp conn _ ver s hs RspNoBody = do
234 -- Not adding Content-Length.
233 -- Not adding Content-Length.
235 -- User agents treats it as Content-Length: 0.
234 -- User agents treats it as Content-Length: 0.
236 composeHeader ver s hs >>= connSendAll conn
235 composeHeader ver s hs >>= connSendAll conn
@@ -238,7 +237,7 @@ sendRsp conn _ _ ver s hs RspNoBody = do
239----------------------------------------------------------------
238----------------------------------------------------------------
241−sendRsp conn _ _ ver s hs (RspBuilder body needsChunked) = do
240+sendRsp conn _ ver s hs (RspBuilder body needsChunked) = do
242 header <- composeHeaderBuilder ver s hs needsChunked
241 header <- composeHeaderBuilder ver s hs needsChunked
243 let hdrBdy
242 let hdrBdy
244 | needsChunked = header <> chunkedTransferEncoding body
243 | needsChunked = header <> chunkedTransferEncoding body
@@ -251,7 +250,7 @@ sendRsp conn _ _ ver s hs (RspBuilder body needsChunked) = do
252----------------------------------------------------------------
251----------------------------------------------------------------
254−sendRsp conn _ _ ver s hs (RspStream streamingBody needsChunked th) = do
253+sendRsp conn _ ver s hs (RspStream streamingBody needsChunked th) = do
255 header <- composeHeaderBuilder ver s hs needsChunked
254 header <- composeHeaderBuilder ver s hs needsChunked
256 (recv, finish) <- newBlazeRecv $ reuseBufferStrategy
255 (recv, finish) <- newBlazeRecv $ reuseBufferStrategy
257 $ toBuilderBuffer (connWriteBuffer conn) (connBufferSize conn)
256 $ toBuilderBuffer (connWriteBuffer conn) (connBufferSize conn)
@@ -275,7 +274,7 @@ sendRsp conn _ _ ver s hs (RspStream streamingBody needsChunked th) = do
276----------------------------------------------------------------
275----------------------------------------------------------------
278−sendRsp conn _ _ _ _ _ (RspRaw withApp src tickle) = do
277+sendRsp conn _ _ _ _ (RspRaw withApp src tickle) = do
279 withApp recv send
278 withApp recv send
280 return (Nothing, Nothing)
279 return (Nothing, Nothing)
@@ -289,8 +288,8 @@ sendRsp conn _ _ _ _ _ (RspRaw withApp src tickle) = do
290-- Sophisticated WAI applications.
289-- Sophisticated WAI applications.
291-- We respect s0. s0 MUST be a proper value.
290-- We respect s0. s0 MUST be a proper value.
292−sendRsp conn ii req ver s0 hs0 (RspFile path (Just part) _ isHead hook) =
291+sendRsp conn ii ver s0 hs0 (RspFile path (Just part) _ isHead hook) =
293− sendRspFile2XX conn ii req ver s0 hs path beg len isHead hook
292+ sendRspFile2XX conn ii ver s0 hs path beg len isHead hook
295 beg = filePartOffset part
294 beg = filePartOffset part
296 len = filePartByteCount part
295 len = filePartByteCount part
@@ -300,23 +299,22 @@ sendRsp conn ii req ver s0 hs0 (RspFile path (Just part) _ isHead hook) =
301-- Simple WAI applications.
300-- Simple WAI applications.
302-- Status is ignored
301-- Status is ignored
303−sendRsp conn ii req ver _ hs0 (RspFile path Nothing idxhdr isHead hook) = do
302+sendRsp conn ii ver _ hs0 (RspFile path Nothing idxhdr isHead hook) = do
304 efinfo <- E.try $ getFileInfo ii path
303 efinfo <- E.try $ getFileInfo ii path
305 case efinfo of
304 case efinfo of
306 Left (_ex :: E.IOException) ->
305 Left (_ex :: E.IOException) ->
307#ifdef WARP_DEBUG
306#ifdef WARP_DEBUG
308 print _ex >>
307 print _ex >>
310− sendRspFile404 conn ii req ver hs0
309+ sendRspFile404 conn ii ver hs0
311 Right finfo -> case conditionalRequest finfo hs0 idxhdr of
310 Right finfo -> case conditionalRequest finfo hs0 idxhdr of
312− WithoutBody s -> sendRsp conn ii req ver s hs0 RspNoBody
311+ WithoutBody s -> sendRsp conn ii ver s hs0 RspNoBody
313− WithBody s hs beg len -> sendRspFile2XX conn ii req ver s hs path beg len isHead hook
312+ WithBody s hs beg len -> sendRspFile2XX conn ii ver s hs path beg len isHead hook
315----------------------------------------------------------------
314----------------------------------------------------------------
317sendRspFile2XX :: Connection
316sendRspFile2XX :: Connection
318 -> InternalInfo
317 -> InternalInfo
320 -> H.HttpVersion
318 -> H.HttpVersion
321 -> H.Status
319 -> H.Status
322 -> H.ResponseHeaders
320 -> H.ResponseHeaders
@@ -326,8 +324,8 @@ sendRspFile2XX :: Connection
328 -> IO (Maybe H.Status, Maybe Integer)
326 -> IO (Maybe H.Status, Maybe Integer)
329−sendRspFile2XX conn ii req ver s hs path beg len isHead hook
327+sendRspFile2XX conn ii ver s hs path beg len isHead hook
330− | isHead = sendRsp conn ii req ver s hs RspNoBody
328+ | isHead = sendRsp conn ii ver s hs RspNoBody
331 | otherwise = do
329 | otherwise = do
332 lheader <- composeHeader ver s hs
330 lheader <- composeHeader ver s hs
333 (mfd, fresher) <- getFd ii path
331 (mfd, fresher) <- getFd ii path
@@ -338,11 +336,10 @@ sendRspFile2XX conn ii req ver s hs path beg len isHead hook
339sendRspFile404 :: Connection
337sendRspFile404 :: Connection
340 -> InternalInfo
338 -> InternalInfo
342 -> H.HttpVersion
339 -> H.HttpVersion
343 -> H.ResponseHeaders
340 -> H.ResponseHeaders
344 -> IO (Maybe H.Status, Maybe Integer)
341 -> IO (Maybe H.Status, Maybe Integer)
345−sendRspFile404 conn ii req ver hs0 = sendRsp conn ii req ver s hs (RspBuilder body True)
342+sendRspFile404 conn ii ver hs0 = sendRsp conn ii ver s hs (RspBuilder body True)
347 s = H.notFound404
344 s = H.notFound404
348 hs = replaceHeader H.hContentType "text/plain; charset=utf-8" hs0
345 hs = replaceHeader H.hContentType "text/plain; charset=utf-8" hs0