stop depending on fake headers
appears to be used only in setting bibref urls and in opengraph metadataforwarded-headers
parent
64a1ce6e96
commit
30684be056
|
@ -420,19 +420,21 @@ class OpenSearch (object):
|
||||||
|
|
||||||
host = cherrypy.request.headers.get ('X-Forwarded-Host', cherrypy.config['host'])
|
host = cherrypy.request.headers.get ('X-Forwarded-Host', cherrypy.config['host'])
|
||||||
self.host = host.split (',')[-1].strip () # keep only the last hub
|
self.host = host.split (',')[-1].strip () # keep only the last hub
|
||||||
|
# turns out X-Forwarded-Protocol (X-Forwarded-Proto is the defacto standaard)
|
||||||
|
# is not a thing and has to be set in HAProxy
|
||||||
self.protocol = cherrypy.request.headers.get ('X-Forwarded-Protocol', 'https')
|
self.protocol = cherrypy.request.headers.get ('X-Forwarded-Protocol', 'https')
|
||||||
|
|
||||||
# sanity check
|
# sanity check
|
||||||
if self.host not in (cherrypy.config['all_hosts']):
|
if self.host not in (cherrypy.config['all_hosts']):
|
||||||
self.host = cherrypy.config['host']
|
self.host = cherrypy.config['host']
|
||||||
if self.protocol not in VALID_PROTOCOLS:
|
if self.protocol not in VALID_PROTOCOLS:
|
||||||
self.protocol = 'http'
|
self.protocol = 'https'
|
||||||
|
|
||||||
self.urlgen = routes.URLGenerator (
|
self.urlgen = routes.URLGenerator (
|
||||||
cherrypy.routes_mapper,
|
cherrypy.routes_mapper,
|
||||||
{
|
{
|
||||||
'HTTP_HOST': self.host,
|
'HTTP_HOST': self.host,
|
||||||
'HTTPS': 1 if self.protocol == 'https' else 0,
|
'HTTPS': 1 ,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -898,7 +900,7 @@ class OpenSearch (object):
|
||||||
|
|
||||||
def format_canonical_bibrec_url (self, row):
|
def format_canonical_bibrec_url (self, row):
|
||||||
""" Generate the rel=canonical bibrec url for a book. """
|
""" Generate the rel=canonical bibrec url for a book. """
|
||||||
return self.url ('bibrec', host = self.file_host, protocol = 'http', id = row.pk, format = None)
|
return self.url ('bibrec', host = self.file_host, protocol = 'https', id = row.pk, format = None)
|
||||||
|
|
||||||
def format_thumb_url (self, row):
|
def format_thumb_url (self, row):
|
||||||
""" Generate the thumb url in results. """
|
""" Generate the thumb url in results. """
|
||||||
|
|
Loading…
Reference in New Issue