4 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
4 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
5 # |
5 # |
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 |
16 from request import wsgirequest |
16 from request import wsgirequest |
17 import webutil |
17 import webutil |
359 "staticurl": staticurl, |
359 "staticurl": staticurl, |
360 "sessionvars": sessionvars}) |
360 "sessionvars": sessionvars}) |
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 |
|