def make_network_absolute(self):
"""Ensures that this URL has a scheme, hostname and port matching that of the current Request URL."""
# Note: It is tempting to want to use request.scheme, request.server_name and request.server_port
# in this method.
#
# But, request.server_name can be different from request_url.hostname; and if this
# happens, and you use it here, the changed url will result in invalidating the existing
# session cookie on the client which is bound to the request_url.hostname by the browser.
#
request_url = Url.get_current_url()
self.scheme = self.scheme or request_url.scheme
self.hostname = self.hostname or request_url.hostname
self.port = self.port or request_url.port
评论列表
文章目录