hgweb: detect Python 3-era libraries and use modern attribute names
authorAugie Fackler <augie@google.com>
Thu, 05 Oct 2017 14:53:52 -0400
changeset 34719 6e1b05692b2c
parent 34718 01206460897a
child 34720 60e7da55e5e6
hgweb: detect Python 3-era libraries and use modern attribute names Differential Revision: https://phab.mercurial-scm.org/D1084
mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Sat Oct 14 15:53:36 2017 -0400
+++ b/mercurial/hgweb/server.py	Thu Oct 05 14:53:52 2017 -0400
@@ -130,7 +130,13 @@
         if query:
             env[r'QUERY_STRING'] = query
 
-        if True:
+        if pycompat.ispy3:
+            if self.headers.get_content_type() is None:
+                env[r'CONTENT_TYPE'] = self.headers.get_default_type()
+            else:
+                env[r'CONTENT_TYPE'] = self.headers.get_content_type()
+            length = self.headers.get('content-length')
+        else:
             if self.headers.typeheader is None:
                 env[r'CONTENT_TYPE'] = self.headers.type
             else: