[PATCH 3 of 7] Use wsgi.url_scheme instead of ad-hoc CGI checks

Wesley J. Landaker wjl at icecavern.net
Thu Jul 12 15:48:47 CDT 2007


# HG changeset patch
# User Wesley J. Landaker <wjl at icecavern.net>
# Date 1184270506 21600
# Node ID 9fc9dc548b0e4cc21a95d1681e3f024e1d712f25
# Parent  8f430b1b3025cbd7735585a3ed3911289654e89f
Use wsgi.url_scheme instead of ad-hoc CGI checks.

Instead of each place in hgweb_mod that needs to check for SSL or get
the protocol scheme (http vs. https) doing it ad-hoc, make them just
look at the wsgi.url_scheme which because of previous patches is now
always set correctly.

diff -r 8f430b1b3025 -r 9fc9dc548b0e mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jul 12 13:58:36 2007 -0600
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jul 12 14:01:46 2007 -0600
@@ -787,7 +787,8 @@ class hgweb(object):
             style = req.form['style'][0]
         mapfile = style_map(self.templatepath, style)
 
-        if req.env.get('HTTPS'):
+        proto = req.env.get['wsgi.url_scheme']
+        if proto == 'https':
             proto = 'https'
             default_port = "443"
         else:
@@ -1070,7 +1071,7 @@ class hgweb(object):
         # replayed
         ssl_req = self.configbool('web', 'push_ssl', True)
         if ssl_req:
-            if not req.env.get('HTTPS'):
+            if req.env.get['wsgi.url_scheme'] != 'https':
                 bail(_('ssl required\n'))
                 return
             proto = 'https'


More information about the Mercurial-devel mailing list