@@ -175,7 +175,7 @@ sendResponse settings conn ii req reqidxhdr src response = do
175 T.tickle th
175 T.tickle th
176 return ret
176 return ret
178− sendResponseNoBody conn ver s hs
178+ _ <- sendRsp conn ii ver s hs RspNoBody
179 logger req s Nothing
179 logger req s Nothing
180 T.tickle th
180 T.tickle th
181 return isPersist
181 return isPersist
@@ -197,10 +197,10 @@ sendResponse settings conn ii req reqidxhdr src response = do
197 rsp = case response of
197 rsp = case response of
198 ResponseFile _ _ path mPart -> RspFile path mPart mRange isHead (T.tickle th)
198 ResponseFile _ _ path mPart -> RspFile path mPart mRange isHead (T.tickle th)
199 ResponseBuilder _ _ b
199 ResponseBuilder _ _ b
200− | isHead -> RspBuilder mempty False
200+ | isHead -> RspNoBody
201 | otherwise -> RspBuilder b needsChunked
201 | otherwise -> RspBuilder b needsChunked
202 ResponseStream _ _ fb
202 ResponseStream _ _ fb
203− | isHead -> RspBuilder mempty False
203+ | isHead -> RspNoBody
204 | otherwise -> RspStream fb needsChunked th
204 | otherwise -> RspStream fb needsChunked th
205 ResponseRaw raw _ -> RspRaw raw src (T.tickle th)
205 ResponseRaw raw _ -> RspRaw raw src (T.tickle th)
206 ret = case response of
206 ret = case response of
@@ -236,7 +236,8 @@ sanitizeHeaderValue v = case S8.lines $ S.filter (/= _cr) v of
237----------------------------------------------------------------
237----------------------------------------------------------------
239−data Rsp = RspFile FilePath (Maybe FilePart) (Maybe HeaderValue) Bool (IO ())
240+ | RspFile FilePath (Maybe FilePart) (Maybe HeaderValue) Bool (IO ())
240 | RspBuilder Builder Bool
241 | RspBuilder Builder Bool
241 | RspStream StreamingBody Bool T.Handle
242 | RspStream StreamingBody Bool T.Handle
242 | RspRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) (IO ByteString) (IO ())
243 | RspRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) (IO ByteString) (IO ())
@@ -250,6 +251,17 @@ sendRsp :: Connection
250 -> H.ResponseHeaders
251 -> H.ResponseHeaders
252 -> IO (Maybe H.Status, Maybe Integer)
253 -> IO (Maybe H.Status, Maybe Integer)
255+----------------------------------------------------------------
257+sendRsp conn _ ver s hs RspNoBody = do
258+ -- Not adding Content-Length.
259+ -- User agents treats it as Content-Length: 0.
260+ composeHeader ver s hs >>= connSendAll conn
261+ return (Just s, Nothing)
263+----------------------------------------------------------------
253sendRsp conn ii ver s0 hs0 (RspFile path mPart mRange isHead hook) = do
265sendRsp conn ii ver s0 hs0 (RspFile path mPart mRange isHead hook) = do
254 ex <- fileRange s0 hs0 path mPart mRange get
266 ex <- fileRange s0 hs0 path mPart mRange get
255 case ex of
267 case ex of
@@ -261,7 +273,7 @@ sendRsp conn ii ver s0 hs0 (RspFile path mPart mRange isHead hook) = do
261 Right (s, hs, beg, len)
273 Right (s, hs, beg, len)
262 | len >= 0 ->
274 | len >= 0 ->
263 if isHead then
275 if isHead then
264− sendRsp conn ii ver s hs (RspBuilder mempty False)
276+ sendRsp conn ii ver s hs RspNoBody
266 lheader <- composeHeader ver s hs
278 lheader <- composeHeader ver s hs
267#ifdef WINDOWS
279#ifdef WINDOWS
@@ -338,15 +350,6 @@ sendRsp conn _ _ _ _ (RspRaw withApp src tickle) = do
338 return bs
350 return bs
339 send bs = connSendAll conn bs >> tickle
351 send bs = connSendAll conn bs >> tickle
341−----------------------------------------------------------------
343−sendResponseNoBody :: Connection
346− -> H.ResponseHeaders
348−sendResponseNoBody conn ver s hs = composeHeader ver s hs >>= connSendAll conn
350----------------------------------------------------------------
353----------------------------------------------------------------
351----------------------------------------------------------------
354----------------------------------------------------------------