D2735: hgweb: use computed base URL from parsed request

2018-03-09 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG56154c4626b9: hgweb: use computed base URL from parsed 
request (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2735?vs=6741=6779

REVISION DETAIL
  https://phab.mercurial-scm.org/D2735

AFFECTED FILES
  mercurial/hgweb/hgweb_mod.py

CHANGE DETAILS

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
@@ -142,21 +142,9 @@
 if typ in allowed or self.configbool('web', 'allow%s' % typ):
 yield {'type': typ, 'extension': spec[2], 'node': nodeid}
 
-def templater(self, wsgireq):
+def templater(self, wsgireq, req):
 # determine scheme, port and server name
 # this is needed to create absolute urls
-
-proto = wsgireq.env.get('wsgi.url_scheme')
-if proto == 'https':
-proto = 'https'
-default_port = '443'
-else:
-proto = 'http'
-default_port = '80'
-
-port = wsgireq.env[r'SERVER_PORT']
-port = port != default_port and (r':' + port) or r''
-urlbase = r'%s://%s%s' % (proto, wsgireq.env[r'SERVER_NAME'], port)
 logourl = self.config('web', 'logourl')
 logoimg = self.config('web', 'logoimg')
 staticurl = (self.config('web', 'staticurl')
@@ -194,7 +182,7 @@
 'logourl': logourl,
 'logoimg': logoimg,
 'staticurl': staticurl,
-'urlbase': urlbase,
+'urlbase': req.advertisedbaseurl,
 'repo': self.reponame,
 'encoding': encoding.encoding,
 'motd': motd,
@@ -396,7 +384,7 @@
 # process the web interface request
 
 try:
-tmpl = rctx.templater(wsgireq)
+tmpl = rctx.templater(wsgireq, req)
 ctype = tmpl('mimetype', encoding=encoding.encoding)
 ctype = templater.stringify(ctype)
 



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2735: hgweb: use computed base URL from parsed request

2018-03-08 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Let's not reinvent URL construction in a function that runs the
  templater.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2735

AFFECTED FILES
  mercurial/hgweb/hgweb_mod.py

CHANGE DETAILS

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
@@ -142,21 +142,9 @@
 if typ in allowed or self.configbool('web', 'allow%s' % typ):
 yield {'type': typ, 'extension': spec[2], 'node': nodeid}
 
-def templater(self, wsgireq):
+def templater(self, wsgireq, req):
 # determine scheme, port and server name
 # this is needed to create absolute urls
-
-proto = wsgireq.env.get('wsgi.url_scheme')
-if proto == 'https':
-proto = 'https'
-default_port = '443'
-else:
-proto = 'http'
-default_port = '80'
-
-port = wsgireq.env[r'SERVER_PORT']
-port = port != default_port and (r':' + port) or r''
-urlbase = r'%s://%s%s' % (proto, wsgireq.env[r'SERVER_NAME'], port)
 logourl = self.config('web', 'logourl')
 logoimg = self.config('web', 'logoimg')
 staticurl = (self.config('web', 'staticurl')
@@ -194,7 +182,7 @@
 'logourl': logourl,
 'logoimg': logoimg,
 'staticurl': staticurl,
-'urlbase': urlbase,
+'urlbase': req.advertisedbaseurl,
 'repo': self.reponame,
 'encoding': encoding.encoding,
 'motd': motd,
@@ -396,7 +384,7 @@
 # process the web interface request
 
 try:
-tmpl = rctx.templater(wsgireq)
+tmpl = rctx.templater(wsgireq, req)
 ctype = tmpl('mimetype', encoding=encoding.encoding)
 ctype = templater.stringify(ctype)
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel