[PATCH 08 of 12] serve: send response headers even if response has no body

Mads Kiilerich mads at kiilerich.com
Fri Jan 11 17:32:52 CST 2013


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1357947109 -3600
# Node ID a2ec86a8062c4aff9191f60a2eae08887f6f7c76
# Parent  618a5e70cd67c258ee08a63036b9733a5ee71b4f
serve: send response headers even if response has no body

The headers would usually be sent anyway because the app did a number of writes
of empty strings.

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -135,6 +135,8 @@
         self.length = None
         for chunk in self.server.application(env, self._start_response):
             self._write(chunk)
+        if not self.sent_headers:
+            self.send_headers()
 
     def send_headers(self):
         if not self.saved_status:


More information about the Mercurial-devel mailing list