base_servlet.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:dancedeets-monorepo 作者: mikelambert 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号