changeset 19877:52ed85d9ac26 stable

hgweb: log headers only if headers were successfully parsed The headers attribute is not initialized in certain error situations (e.g. http 400 bad request). Check for self.headers before we attempt to access it.
author David Soria Parra <dsp@experimentalworks.net>
date Tue, 01 Oct 2013 09:54:46 +0200
parents c172660eee01
children 21de61bc2ab5
files mercurial/hgweb/server.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/server.py	Mon Oct 07 17:47:19 2013 -0400
+++ b/mercurial/hgweb/server.py	Tue Oct 01 09:54:46 2013 +0200
@@ -60,7 +60,10 @@
         self._log_any(self.server.accesslog, format, *args)
 
     def log_request(self, code='-', size='-'):
-        xheaders = [h for h in self.headers.items() if h[0].startswith('x-')]
+        xheaders = []
+        if util.safehasattr(self, 'headers'):
+            xheaders = [h for h in self.headers.items()
+                        if h[0].startswith('x-')]
         self.log_message('"%s" %s %s%s',
                          self.requestline, str(code), str(size),
                          ''.join([' %s:%s' % h for h in sorted(xheaders)]))