PATCH: hgweb_dir.py - Work in proxied environments
Michael Tharp
gxti at partiallystapled.com
Mon Aug 16 14:19:17 CDT 2010
On 08/16/2010 10:14 AM, Dirkjan Ochtman wrote:
> On Mon, Aug 16, 2010 at 16:21, Steve Kemp<steve at steve.org.uk> wrote:
>> I see no downside to using HTTP_HOST rather than SERVER_NAME, so the patch
>> below makes that change.
>
> Me neither, so I'm inclined to take this. Anyone know any disadvantage?
The Host header includes any port supplied by the client, so adding one
again will cause problems if something other than 80/443 is used.
e.g. http://foobar/ -> foobar, http://foobar:8080/ -> foobar:8080
Corrected patch below. Sorry in advance if it gets mangled.
-- m. tharp
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -218,7 +218,7 @@
port = req.env["SERVER_PORT"]
port = port != default_port and (":" + port) or ""
- urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
+ urlbase = '%s://%s' % (proto, req.env['HTTP_HOST'])
staticurl = self.config("web", "staticurl") or req.url + 'static/'
if not staticurl.endswith('/'):
staticurl += '/'
More information about the Mercurial-devel
mailing list