mozilla/bouncer-tests — pull request #53 by superawesome (2014-08-14 18:21:51+00:00)
Title: Send Connection: close header on HEAD requests

HEAD requests can behave oddly... if you don't explicitly tell the server it can close the connection after serving the request, it will sometimes leave the connection open, and eventually the client or server will time out.

You can test this directly, with curl:
curl -v -XHEAD 'http://download.mozilla.org/?lang=sw&product=firefox-16.0b6&os=osx' -o /dev/null
(hangs for a while after receiving the headers)
vs
curl -v -XHEAD -H 'Connection: close' 'http://download.mozilla.org/?lang=sw&product=firefox-16.0b6&os=osx' -o /dev/null
(exits immediately after receiving the headers)

In this case, I think we definitely want to be creating new connections for each request (not using keep-alives), so this is actually the proper way to do it in the first place. The RFC indicates that you should always send this header, unless you want to make additional requests on the same connection. We don't, so we should send it.