diff --git a/warp/Network/Wai/Handler/Warp/Response.hs b/warp/Network/Wai/Handler/Warp/Response.hs index e8bc8df5d..d9121f0a3 100644 --- a/warp/Network/Wai/Handler/Warp/Response.hs +++ b/warp/Network/Wai/Handler/Warp/Response.hs @@ -121,7 +121,7 @@ sendResponse -> IO Bool -- ^ Returing True if the connection is persistent. sendResponse settings conn ii th req reqidxhdr src response = do - hs <- addAltSvc settings <$> addServerAndDate hs0 + hs <- addConnection . addAltSvc settings <$> addServerAndDate hs0 if hasBody s then do -- The response to HEAD does not have body. @@ -149,6 +149,9 @@ sendResponse settings conn ii th req reqidxhdr src response = do s = responseStatus response hs0 = sanitizeHeaders $ responseHeaders response rspidxhdr = indexResponseHeader hs0 + addConnection hs = if (hasBody s && not ret) || (not (hasBody s) && not isPersist) + then (H.hConnection, "close") : hs + else hs getdate = getDate ii addServerAndDate = addDate getdate rspidxhdr . addServer defServer rspidxhdr (isPersist, isChunked0) = infoFromRequest req reqidxhdr