def redirect(self, url, **kwargs):
if url.startswith('/'):
spliturl = urlparse.urlsplit(self.request.url)
# Redirect to the www.dancedeets.com domain if they requested the raw hostname
domain = self._get_full_hostname() if spliturl.netloc == 'dancedeets.com' else spliturl.netloc
# Redirect to https on prod, as relying on url.scheme would send it back to http, due to the nginx http-based proxy
scheme = 'https' if self.request.app.prod_mode else 'http'
new_url = urlparse.urlunsplit([
scheme,
domain,
spliturl.path,
spliturl.query,
spliturl.fragment,
])
url = str(urlparse.urljoin(new_url, url))
return super(BaseRequestHandler, self).redirect(url, **kwargs)
评论列表
文章目录