Provide a way to disable hostname canonicalization
mithrandi opened this issue · 1 comments
mithrandi commented
The ability to have multiple canonical hostnames was planned previously, but for sites that don't need to use the websharing-by-username-in-hostname feature, there's no real need to care about canonicalization; resources can just be served from whatever hostname the page was requested from. All that is required is a way to turn off the canonicalization.
mithrandi commented
Very rough sketch of how to implement this, copied from an ad-hoc patch we have deployed already:
===================================================================
--- Mantissa/xmantissa/publicweb.py (revision 18024)
+++ Mantissa/xmantissa/publicweb.py (working copy)
@@ -805,7 +805,7 @@
action' and 'error' slots in the template accordingly.
"""
generator = ixmantissa.ISiteURLGenerator(self.store)
- url = generator.rootURL(IRequest(ctx))
+ url = URL.fromString('/')
url = url.child('__login__')
for seg in self.segments:
url = url.child(seg)
Index: Mantissa/xmantissa/web.py
===================================================================
--- Mantissa/xmantissa/web.py (revision 18024)
+++ Mantissa/xmantissa/web.py (working copy)
@@ -148,10 +148,11 @@
this website is available.
"""
host = request.getHeader('host') or self.hostname
- if ':' in host:
- host = host.split(':', 1)[0]
- if (host == self.hostname or
- host.startswith('www.') and host[len('www.'):] == self.hostname):
+ #if ':' in host:
+ # host = host.split(':', 1)[0]
+ #if (host == self.hostname or
+ # host.startswith('www.') and host[len('www.'):] == self.hostname):
+ if True:
return URL(scheme='', netloc='', pathsegs=[''])
else:
if request.isSecure():
@@ -365,7 +366,7 @@
"""
if getattr(self.wrappedResource, 'needsSecure', False):
request = IRequest(context)
- url = self.urlGenerator.encryptedRoot()
+ url = self.urlGenerator.encryptedRoot(request.getHeader('Host'))
if url is not None:
for seg in request.prepath:
url = url.child(seg)
I think the change to publicweb
is not actually needed given the change to SiteConfiguration
but this needs to be tested.