def redirect_request(self, req, fp, code, msg, headers, newurl): """Return a Request or None in response to a redirect. See `urllib2.HTTPRedirectHandler`. If the original request is a POST request, the request's payload will be preserved in the redirect and the returned request will also be a POST request. """ # If we can't handle this redirect, # HTTPRedirectHandler.redirect_request() will raise an # HTTPError. We call the superclass here in the old fashion # since HTTPRedirectHandler isn't a new-style class. new_request = HTTPRedirectHandler.redirect_request( self, req, fp, code, msg, headers, newurl) # If the old request is a POST request, the payload will be # preserved. Note that we don't need to test for the POST-ness # of the old request; if its data attribute - its payload - is # not None it's a POST request, if it's None it's a GET request. # We can therefore just copy the data from the old request to # the new without worrying about breaking things. new_request.data = req.data new_request.timeout = req.timeout return new_request
def redirect_request(self, req, fp, code, msg, headers, newurl): """Return a Request or None in response to a redirect. See `urllib2.HTTPRedirectHandler`. If the original request is a POST request, the request's payload will be preserved in the redirect and the returned request will also be a POST request. """ # If we can't handle this redirect, # HTTPRedirectHandler.redirect_request() will raise an # HTTPError. We call the superclass here in the old fashion # since HTTPRedirectHandler isn't a new-style class. new_request = HTTPRedirectHandler.redirect_request( self, req, fp, code, msg, headers, newurl) # If the old request is a POST request, the payload will be # preserved. Note that we don't need to test for the POST-ness # of the old request; if its data attribute - its payload - is # not None it's a POST request, if it's None it's a GET request. # We can therefore just copy the data from the old request to # the new without worrying about breaking things. new_request.data = req.data new_request.timeout = req.timeout return new_request
def redirect_request(self, req, fp, code, msg, hdrs, newurl): self._counter += 1 if (self._counter > self._maxRedirects): raise HTTPError(req.get_full_url(), code, 'Reached the maximum number of redirects', hdrs, fp) else: # TODO: really reuse referer-header? return HTTPRedirectHandler.redirect_request( self, req, fp, code, msg, hdrs, newurl)
def redirect_request(self, req, fp, code, msg, headers, newurl): new_req = HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, headers, newurl) req.redirect_code = code return new_req
def redirect_request(self, req, fp, code, msg, hdrs, newurl): if newurl.startswith('https://localhost.admin.eutaxia.eu:5000/login/%s' % provider): raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) return HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, hdrs, newurl)
def redirect_request(self, *args): new_request = HTTPRedirectHandler.redirect_request(self, *args) # We need to add a cookie from the cookie_jar self.cookie_jar.add_cookie_header(new_request) return new_request