PATCH: hgweb_dir.py - Work in proxied environments
Matt Mackall
mpm at selenic.com
Mon Aug 16 17:49:50 CDT 2010
On Mon, 2010-08-16 at 15:19 -0400, Michael Tharp wrote:
> 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 += '/'
My understanding is that HTTP_HOST isn't always available. In
particular, with HTTP 1.0 clients. Not sure if that matters any more.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list