diff --git a/warp/ChangeLog.md b/warp/ChangeLog.md index 89e9d41f..8cad78c5 100644 --- a/warp/ChangeLog.md +++ b/warp/ChangeLog.md @@ -1,5 +1,11 @@ # ChangeLog for warp + +## 3.4.2 + +* Respond with `Connection: close` header if connection is to be closed after a request. + [#958](https://github.com/yesodweb/wai/pull/958) + ## 3.4.1 * Using time-manager v0.1.0, and auto-update v0.2.0. diff --git a/warp/Network/Wai/Handler/Warp/Response.hs b/warp/Network/Wai/Handler/Warp/Response.hs index e8bc8df5..d9121f0a 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 diff --git a/warp/warp.cabal b/warp/warp.cabal index 99b266f8..4f939e6d 100644 --- a/warp/warp.cabal +++ b/warp/warp.cabal @@ -1,5 +1,5 @@ Name: warp -Version: 3.4.1 +Version: 3.4.2 Synopsis: A fast, light-weight web server for WAI applications. License: MIT License-file: LICENSE