Make hg serve set the wsgi.url_scheme property correctly.
authorWesley J. Landaker <wjl@icecavern.net>
Thu, 12 Jul 2007 13:58:36 -0600
changeset 4870 8f430b1b3025
parent 4869 be591b740e0f
child 4871 d787d9ad67cc
Make hg serve set the wsgi.url_scheme property correctly. This fixes the bug where hg serve with SSL will always detect the wrong urlbase for templates. This is also part of unifying the CGI interface and hg serve interface to both use standard wsgi.
mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Thu Jul 12 13:55:20 2007 -0600
+++ b/mercurial/hgweb/server.py	Thu Jul 12 13:58:36 2007 -0600
@@ -37,6 +37,9 @@
             self.handler.log_error("HG error:  %s", msg)
 
 class _hgwebhandler(object, BaseHTTPServer.BaseHTTPRequestHandler):
+
+    url_scheme = 'http'
+    
     def __init__(self, *args, **kargs):
         self.protocol_version = 'HTTP/1.1'
         BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kargs)
@@ -104,7 +107,7 @@
                 env[hkey] = hval
         env['SERVER_PROTOCOL'] = self.request_version
         env['wsgi.version'] = (1, 0)
-        env['wsgi.url_scheme'] = 'http'
+        env['wsgi.url_scheme'] = type(self).url_scheme
         env['wsgi.input'] = self.rfile
         env['wsgi.errors'] = _error_logger(self)
         env['wsgi.multithread'] = isinstance(self.server,
@@ -168,6 +171,9 @@
         self.wfile.flush()
 
 class _shgwebhandler(_hgwebhandler):
+
+    url_scheme = 'https'
+    
     def setup(self):
         self.connection = self.request
         self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)