Show More
@@ -51,6 +51,33 b' def urlrepos(prefix, roothead, paths):' | |||||
51 | yield (prefix + '/' + |
|
51 | yield (prefix + '/' + | |
52 | util.pconvert(path[len(roothead):]).lstrip('/')).strip('/'), path |
|
52 | util.pconvert(path[len(roothead):]).lstrip('/')).strip('/'), path | |
53 |
|
53 | |||
|
54 | def geturlcgivars(baseurl, port): | |||
|
55 | """ | |||
|
56 | Extract CGI variables from baseurl | |||
|
57 | ||||
|
58 | >>> geturlcgivars("http://host.org/base", "80") | |||
|
59 | ('host.org', '80', '/base') | |||
|
60 | >>> geturlcgivars("http://host.org:8000/base", "80") | |||
|
61 | ('host.org', '8000', '/base') | |||
|
62 | >>> geturlcgivars('/base', 8000) | |||
|
63 | ('', '8000', '/base') | |||
|
64 | >>> geturlcgivars("base", '8000') | |||
|
65 | ('', '8000', '/base') | |||
|
66 | >>> geturlcgivars("http://host", '8000') | |||
|
67 | ('host', '8000', '/') | |||
|
68 | >>> geturlcgivars("http://host/", '8000') | |||
|
69 | ('host', '8000', '/') | |||
|
70 | """ | |||
|
71 | u = util.url(baseurl) | |||
|
72 | name = u.host or '' | |||
|
73 | if u.port: | |||
|
74 | port = u.port | |||
|
75 | path = u.path or "" | |||
|
76 | if not path.startswith('/'): | |||
|
77 | path = '/' + path | |||
|
78 | ||||
|
79 | return name, str(port), path | |||
|
80 | ||||
54 | class hgwebdir(object): |
|
81 | class hgwebdir(object): | |
55 | refreshinterval = 20 |
|
82 | refreshinterval = 20 | |
56 |
|
83 | |||
@@ -366,11 +393,7 b' class hgwebdir(object):' | |||||
366 |
|
393 | |||
367 | def updatereqenv(self, env): |
|
394 | def updatereqenv(self, env): | |
368 | if self._baseurl is not None: |
|
395 | if self._baseurl is not None: | |
369 | u = util.url(self._baseurl) |
|
396 | name, port, path = geturlcgivars(self._baseurl, env['SERVER_PORT']) | |
370 |
env['SERVER_NAME'] = |
|
397 | env['SERVER_NAME'] = name | |
371 | if u.port: |
|
398 | env['SERVER_PORT'] = port | |
372 | env['SERVER_PORT'] = u.port |
|
|||
373 | path = u.path or "" |
|
|||
374 | if not path.startswith('/'): |
|
|||
375 | path = '/' + path |
|
|||
376 | env['SCRIPT_NAME'] = path |
|
399 | env['SCRIPT_NAME'] = path |
General Comments 0
You need to be logged in to leave comments.
Login now