##// END OF EJS Templates
hgweb: use url.url when setting CGI environment variables
Brodie Rao -
r13821:a35aff48 default
parent child Browse files
Show More
@@ -6,10 +6,10 b''
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 import os, re, time, urlparse
9 import os, re, time
10 from mercurial.i18n import _
10 from mercurial.i18n import _
11 from mercurial import ui, hg, util, templater
11 from mercurial import ui, hg, util, templater
12 from mercurial import error, encoding
12 from mercurial import error, encoding, url
13 from common import ErrorResponse, get_mtime, staticfile, paritygen, \
13 from common import ErrorResponse, get_mtime, staticfile, paritygen, \
14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
15 from hgweb_mod import hgweb
15 from hgweb_mod import hgweb
@@ -361,17 +361,9 b' class hgwebdir(object):'
361 return tmpl
361 return tmpl
362
362
363 def updatereqenv(self, env):
363 def updatereqenv(self, env):
364 def splitnetloc(netloc):
365 if ':' in netloc:
366 return netloc.split(':', 1)
367 else:
368 return (netloc, None)
369
370 if self._baseurl is not None:
364 if self._baseurl is not None:
371 urlcomp = urlparse.urlparse(self._baseurl)
365 u = url.url(self._baseurl)
372 host, port = splitnetloc(urlcomp[1])
366 env['SERVER_NAME'] = u.host
373 path = urlcomp[2]
367 if u.port:
374 env['SERVER_NAME'] = host
368 env['SERVER_PORT'] = u.port
375 if port:
369 env['SCRIPT_NAME'] = '/' + u.path
376 env['SERVER_PORT'] = port
377 env['SCRIPT_NAME'] = path
General Comments 0
You need to be logged in to leave comments. Login now