def redirect(self, url: QUrl) -> None: if self._redirected: raise interceptors.RedirectException("Request already redirected.") if self._webengine_info is None: raise interceptors.RedirectException("Request improperly initialized.") # Redirecting a request that contains payload data is not allowed. # To be safe, abort on any request not in a whitelist. if (self._webengine_info.requestMethod() not in self._WHITELISTED_REQUEST_METHODS): raise interceptors.RedirectException( "Request method does not support redirection.") self._webengine_info.redirect(url) self._redirected = True
def redirect(self, url: QUrl, *, ignore_unsupported: bool = False) -> None: if self._redirected: raise interceptors.RedirectException("Request already redirected.") if self._webengine_info is None: raise interceptors.RedirectException( "Request improperly initialized.") # Redirecting a request that contains payload data is not allowed. # To be safe, abort on any request not in a whitelist. verb = self._webengine_info.requestMethod() if verb not in self._WHITELISTED_REQUEST_METHODS: msg = ( f"Request method {verb} for {self.request_url.toDisplayString()} " "does not support redirection.") if ignore_unsupported: log.network.debug(msg) return raise interceptors.RedirectException(msg) self._webengine_info.redirect(url) self._redirected = True