Create a new redirect response to the previously intended backend location.
429739
public function redirectIntended($path, $status = 302, $headers = [], $secure = null)
    {
        return Redirect::intended($this->uri() . '/' . $path, $status, $headers, $secure);
    }
652834
def redirect_ext(to, params_=None, anchor_=None, permanent_=False, args=None, kwargs=None):
    
    if permanent_:
        redirect_class = HttpResponsePermanentRedirect
    else:
        redirect_class = HttpResponseRedirect
    return redirect_class(resolve_url_ext(to, params_, anchor_, args, kwargs))
1216998
def dispatch_request(self, *args, **kwargs):
        
        if request.method in ('POST', 'PUT'):
            return_url, context = self.post(*args, **kwargs)
            if return_url is not None:
                return redirect(return_url)
        elif request.method in ('GET', 'HEAD'):
            context = self.get(*args, **kwargs)
        return self.render_response(self.context(context))
744927
protected static function createRedirectResponse($url, $code, $headers)
    {
        $r = new RedirectResponse($url, $code, $headers);
        $r->setRequest(Request::getInstance());

        return $r;
    }
1295657
public static function back()
    {
        $referer = $_SERVER['HTTP_REFERER'];

        if (! empty($referer)) {
            return self::redirect($referer);
        }

        return self::redirect('/');
    }
226353
def _RedirectToRemoteHelp(self, path):
    """"""
    allowed_chars = set(string.ascii_letters + string.digits + "._-/")
    if not set(path) <= allowed_chars:
      raise RuntimeError("Unusual chars in path %r - "
                         "possible exploit attempt." % path)

    target_path = os.path.join(config.CONFIG["AdminUI.docs_location"], path)

    # We have to redirect via JavaScript to have access to and to preserve the
    # URL hash. We don't know the hash part of the url on the server.
    return werkzeug_wrappers.Response(
        """
<script>
var friendly_hash = window.location.hash;
window.location = '%s' + friendly_hash;
</script>
""" % target_path,
        mimetype="text/html")
89784
protected function redirect($location, $status = 302, $headers = array()) {
		// Check if a output action has be already performed
		$this->_checkIfPerformed();

		// Create a redirect
		$redirectResponse = \Symfony\Component\HttpFoundation\RedirectResponse::create($location, $status, $headers);

		// Add request informationen
		$redirectResponse->prepare($this->application->requestStack->getCurrentRequest());

		// Replace response object
		$this->application->response = $redirectResponse;

		// Don't use a template
		$this->useTemplate(false, $status);
	}
910187
def raise_on_self_redirect(self, params, cdx, status_code, location_url):
        
        if cdx.get('is_live'):
            return

        if not status_code.startswith('3') or status_code == '304':
            return

        request_url = params['url'].lower()
        if not location_url:
            return


        location_url = location_url.lower()
        if location_url.startswith('/'):
            host = urlsplit(cdx['url']).netloc
            location_url = host + location_url

        location_url = location_url.split('://', 1)[-1].rstrip('/')
        request_url = request_url.split('://', 1)[-1].rstrip('/')

        self_redir = False

        if request_url == location_url:
            self_redir = True
        elif params.get('sr-urlkey'):
            # if new location canonicalized matches old key, also self-redirect
            if canonicalize(location_url) == params.get('sr-urlkey'):
                self_redir = True

        if self_redir:
            msg = 'Self Redirect {0} -> {1}'
            msg = msg.format(request_url, location_url)
            params['sr-urlkey'] = cdx['urlkey']
            raise LiveResourceException(msg)
1204797
function Request_redirect(url, isTemp) {
        logger.info('Request.redirect:', {
            url: url,
            isTemp: isTemp
        });
        this.addHeader('Location', url);
        this.stopPromiseChain();
        this.isRendered = true;
        if (Type.isBoolean(isTemp) && !!isTemp) {
            this.response.writeHead(302, this.headers);
        } else {
            this.response.writeHead(301, this.headers);
        }
        this.response.end('Redirect to:' + url);
    }
687906
def default_redirect(request, fallback_url, **kwargs):
    
    redirect_field_name = kwargs.get("redirect_field_name", "next")
    next = request.POST.get(redirect_field_name,
                            request.GET.get(redirect_field_name, ''))
    if not next:
        # try the session if available
        if hasattr(request, "session"):
            session_key_value = kwargs.get("session_key_value", "redirect_to")
            next = request.session.get(session_key_value)
    is_safe = functools.partial(
        ensure_safe_url,
        allowed_protocols=kwargs.get("allowed_protocols"),
        allowed_host=request.get_host()
    )
    redirect_to = next if next and is_safe(next) else fallback_url
    # perform one last check to ensure the URL is safe to redirect to. if it
    # is not then we should bail here as it is likely developer error and
    # they should be notified
    is_safe(redirect_to, raise_on_fail=True)
    return redirect_to
142213
private function _redirect($location)
	{
		$locationUrl = new Url($location);

		// if the location header was relative (bleh) add the host
		if(!$locationUrl->hasHost())
		{
			$locationUrl = $this->_url->getUrlForPath($location);
		}

		if($this->_redirects > self::MAX_REDIRECTS)
		{
			throw new Error\BadRequest("Exceeded maximum redirects");
		}

		$this->_redirects++;

		return $this->_dispatchRequest(
			new Request('GET', $locationUrl, $this->_headers));
	}
107400
public function redirectIntended()
    {
        // Make sure we have a route.
        if (is_null($this->route)) {
            throw new \Exception('No route has been provided.  Please use route() to add one.');
        }

        // If this response passed, show the success message.
        if ($this->success) {
            return redirect()
                ->intended($this->route)
                ->with('message', $this->message);
        }

        // If this response failed, show the error message.
        return redirect($this->route)
            ->with('error', $this->message);
    }
918458
private boolean processRedirectResponse(final HttpMethod method)
     throws RedirectException {
		//get the location header to find out where to redirect to
		Header locationHeader = method.getResponseHeader("location");
		if (locationHeader == null) {
			// got a redirect response, but no location header
			LOG.error("Received redirect response " + method.getStatusCode()
					+ " but no location header");
			return false;
		}
		String location = locationHeader.getValue();
		if (LOG.isDebugEnabled()) {
			LOG.debug("Redirect requested to location '" + location + "'");
		}
        
		//rfc2616 demands the location value be a complete URI
		//Location       = "Location" ":" absoluteURI
		URI redirectUri = null;
		URI currentUri = null;

		try {
			currentUri = new URI(
				this.conn.getProtocol().getScheme(),
				null,
                this.conn.getHost(), 
                this.conn.getPort(), 
				method.getPath()
			);
			
            String charset = method.getParams().getUriCharset();
            redirectUri = new URI(location, true, charset);
			
            if (redirectUri.isRelativeURI()) {
				if (this.params.isParameterTrue(HttpClientParams.REJECT_RELATIVE_REDIRECT)) {
					LOG.warn("Relative redirect location '" + location + "' not allowed");
					return false;
				} else { 
					//location is incomplete, use current values for defaults
					LOG.debug("Redirect URI is not absolute - parsing as relative");
					redirectUri = new URI(currentUri, redirectUri);
				}
			} else {
                // Reset the default params
                method.getParams().setDefaults(this.params);
            }
            method.setURI(redirectUri);
            hostConfiguration.setHost(redirectUri);
		} catch (URIException ex) {
            throw new InvalidRedirectLocationException(
                    "Invalid redirect location: " + location, location, ex);
		}

        if (this.params.isParameterFalse(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS)) {
            if (this.redirectLocations == null) {
                this.redirectLocations = new HashSet<URI>();
            }
            this.redirectLocations.add(currentUri);
            try {
                if(redirectUri.hasQuery()) {
                    redirectUri.setQuery(null);
                }
            } catch (URIException e) {
                // Should never happen
                return false;
            }

            if (this.redirectLocations.contains(redirectUri)) {
                throw new CircularRedirectException("Circular redirect to '" +
                    redirectUri + "'");
            }
        }

		if (LOG.isDebugEnabled()) {
			LOG.debug("Redirecting from '" + currentUri.getEscapedURI()
				+ "' to '" + redirectUri.getEscapedURI());
		}
        //And finally invalidate the actual authentication scheme
                method.getHostAuthState().invalidate(); 
                method.getProxyAuthState().invalidate(); 
		return true;
	}
558941
function createFallbackHandler( flow ) {
      const { redirectOn, places } = flow;
      return path => {
         log.warn( `Received request for unknown route "${path}".` );
         if( redirectOn.unknownPlace in places ) {
            log.trace( `- Redirecting to error place ("${redirectOn.unknownPlace}").` );
            handleRouteChange( places[ redirectOn.unknownPlace ], {} );
         }
         else if( DEFAULT_PLACE in places ) {
            log.trace( `- Redirecting to default place ("${DEFAULT_PLACE}").` );
            handleRouteChange( places[ DEFAULT_PLACE ], {} );
         }
         else {
            log.trace( '- Got no unknownPlace redirect and no default place. Doing nothing.' );
         }
      };
   }
766949
def check_if_redirect(url):
    
    response = head(url, headers={'User-Agent': USER_AGENT})
    if response.status_code >= 300 and response.status_code < 400:
        return response.headers['location']

    return None
217546
def assert_redirect(self, response, expected_url=None):
        
        self.assertIn(
            response.status_code,
            self.redirect_codes,
            self._get_redirect_assertion_message(response),
        )
        if expected_url:
            location_header = response._headers.get('location', None)
            self.assertEqual(
                location_header,
                ('Location', str(expected_url)),
                'Response should redirect to {0}, but it redirects to {1} instead'.format(
                    expected_url,
                    location_header[1],
                )
            )
59085
def _call_backend(self, method, default, *args, **kwargs):
        """"""
        meth = getattr(self.backend, method, None)
        if meth is None:
            return default
        else:
            return meth(*args, **kwargs)