Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warp: Send Connection: close when closing the connection #958

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions warp/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 4 additions & 1 deletion warp/Network/Wai/Handler/Warp/Response.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion warp/warp.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading