def extract_wsgi(self, environ, headers): """Extract the server's set-cookie headers as cookies into the cookie jar. """ self.extract_cookies( _TestCookieResponse(headers), U2Request(get_current_url(environ)), )
def fix_headers(self, environ): """This is automatically called right before the response is started and should fix common mistakes in headers. For example location headers are joined with the root URL here. """ if 'Location' in self.headers: self.headers['Location'] = urlparse.urljoin( get_current_url(environ, root_only=True), self.headers['Location'] )
def fix_headers(self, environ): """ This is automatically called right before the response is started and should fix common mistakes in headers. For example location headers are joined with the root URL here. """ if 'Location' in self.headers: self.headers['Location'] = urlparse.urljoin( get_current_url(environ, host_only=True), self.headers['Location'] )
def fix_headers(self, environ): """This is automatically called right before the response is started and should fix common mistakes in headers. For example location headers are joined with the root URL here. """ if 'Location' in self.headers: self.headers['Location'] = urlparse.urljoin( get_current_url(environ, root_only=True), self.headers['Location'] ) if 100 <= self.status_code < 200 or self.status_code == 204: self.headers['Content-Length'] = 0 elif self.status_code == 304: remove_entity_headers(self.headers)
def host_url(self): """Just the host with scheme.""" return get_current_url(self.environ, host_only=True)
def url_root(self): """The full URL root (with hostname), this is the application root.""" return get_current_url(self.environ, True)
def base_url(self): """Like `url` but without the querystring""" return get_current_url(self.environ, strip_querystring=True)
def url(self): """The reconstructed current URL""" return get_current_url(self.environ)