Patchwork [10,of,12] hgweb: don't pass empty response chunks on

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 11, 2013, 11:32 p.m.
Message ID <d085fef69932009da56e.1357947174@mk-desktop>
Download mbox | patch
Permalink /patch/570/
State Accepted
Commit 3fbdbeab38cc1fec9df1d1b0ed4018db5a54cb2c
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 d085fef69932009da56e66d46b75da5c885cf91a
# Parent  cb969323468b05ce085de63865cdd4c08fb8f994
hgweb: don't pass empty response chunks on

hgweb internals will often produce empty writes - especially when returning
compressed data.  hgweb is no middleware application and there is thus no
reason to pass them on to be processed in other layers.

Patch

diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py
--- a/mercurial/hgweb/request.py
+++ b/mercurial/hgweb/request.py
@@ -109,11 +109,12 @@ 
             self.server_write = None
 
     def write(self, thing):
-        try:
-            self.server_write(thing)
-        except socket.error, inst:
-            if inst[0] != errno.ECONNRESET:
-                raise
+        if thing:
+            try:
+                self.server_write(thing)
+            except socket.error, inst:
+                if inst[0] != errno.ECONNRESET:
+                    raise
 
     def writelines(self, lines):
         for line in lines: