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

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 11, 2013, 11:32 p.m.
Message ID <a2ec86a8062c4aff9191.1357947172@mk-desktop>
Download mbox | patch
Permalink /patch/568/
State Accepted
Commit c007e5c54b161b763563958ddb94bff8f6fe927e
Headers show

Comments

Mads Kiilerich - Jan. 11, 2013, 11:32 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@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.

Patch

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: