@@ -186,12 +186,14 @@ sendResponse defServer conn ii req reqidxhdr src response = do
186186 isChunked = not isHead && isChunked0
187187 (isKeepAlive, needsChunked) = infoFromResponse rspidxhdr (isPersist,isChunked)
188188 isHead = requestMethod req == H.methodHead
189− rsp
190− | isHead = RspBuilder mempty False
191− | otherwise = case response of
192− ResponseFile _ _ path mPart -> RspFile path mPart mRange (T.tickle th)
193− ResponseBuilder _ _ b -> RspBuilder b needsChunked
194− ResponseStream _ _ fb -> RspStream fb needsChunked th
189+ rsp = case response of
190+ ResponseFile _ _ path mPart -> RspFile path mPart mRange isHead (T.tickle th)
191+ ResponseBuilder _ _ b
192+ | isHead -> RspBuilder mempty False
193+ | otherwise -> RspBuilder b needsChunked
194+ ResponseStream _ _ fb
195+ | isHead -> RspBuilder mempty False
196+ | otherwise -> RspStream fb needsChunked th
195197 ResponseRaw raw _ -> RspRaw raw src (T.tickle th)
196198 ret = case response of
197199 ResponseFile {} -> isPersist
@@ -226,7 +228,7 @@ sanitizeHeaderValue v = case S8.lines $ S.filter (/= _cr) v of
226228
227229----------------------------------------------------------------
228230
229−data Rsp = RspFile FilePath (Maybe FilePart) (Maybe HeaderValue) (IO ())
231+data Rsp = RspFile FilePath (Maybe FilePart) (Maybe HeaderValue) Bool (IO ())
230232 | RspBuilder Builder Bool
231233 | RspStream StreamingBody Bool T.Handle
232234 | RspRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) (IO ByteString) (IO ())
@@ -240,7 +242,7 @@ sendRsp :: Connection
240242 -> H.ResponseHeaders
241243 -> Rsp
242244 -> IO ()
243−sendRsp conn ii ver s0 hs0 (RspFile path mPart mRange hook) = do
245+sendRsp conn ii ver s0 hs0 (RspFile path mPart mRange isHead hook) = do
244246 ex <- fileRange s0 hs0 path mPart mRange get
245247 case ex of
246248 Left _ex ->
@@ -249,21 +251,24 @@ sendRsp conn ii ver s0 hs0 (RspFile path mPart mRange hook) = do
249251#endif
250252 sendRsp conn ii ver s2 hs2 (RspBuilder body True)
251253 Right (s, hs, beg, len)
252− | len >= 0 -> do
253− lheader <- composeHeader ver s hs
254+ | len >= 0 ->
255+ if isHead then
256+ sendRsp conn ii ver s hs (RspBuilder mempty False)
257+ else do
258+ lheader <- composeHeader ver s hs
254259#ifdef WINDOWS
255− let fid = FileId path Nothing
256− hook' = hook
260+ let fid = FileId path Nothing
261+ hook' = hook
257262#else
258− (mfd, hook') <- case mfdc of
259− -- settingsFdCacheDuration is 0
260− Nothing -> return (Nothing, hook)
261− Just fdc -> do
262− (fd, fresher) <- F.getFd fdc path
263− return (Just fd, hook >> fresher)
264− let fid = FileId path mfd
263+ (mfd, hook') <- case mfdc of
264+ -- settingsFdCacheDuration is 0
265+ Nothing -> return (Nothing, hook)
266+ Just fdc -> do
267+ (fd, fresher) <- F.getFd fdc path
268+ return (Just fd, hook >> fresher)
269+ let fid = FileId path mfd
265270#endif
266− connSendFile conn fid beg len hook' [lheader]
271+ connSendFile conn fid beg len hook' [lheader]
267272 | otherwise ->
268273 sendRsp conn ii ver H.status416
269274 (filter (\(k, _) -> k /= "content-length") hs)