Header Redirect.

@param string $uri
@param string $type
@param int    $httpResponseCode
971720
public function redirectTo($uri, $type = 'location', $httpResponseCode = 302)
    {
        $uri = str_replace(['.', '/'], '/', $uri);

        if (!preg_match('#^https?://#i', $uri)) {
            $uri = $this->sitePath($uri);
        }

        switch ($type) {
            case 'refresh':
                header('Refresh:0;url='.$uri);
                break;
            case 'location':
                header('Location: '.$uri, true, $httpResponseCode);
                break;
        }
        exit;
    }
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;
	}
1330643
private <T> HttpResponse sendRequest(final URI uri, final HttpRequest<T> request) throws IOException, ProtocolException
	{
		final HttpURLConnection connection;
		try
		{
			connection = mConnectionFactory.httpUrlConnection(uri);
		}
		catch (IllegalArgumentException e)
		{
			throw new ProtocolException("The given URI is not applicable to HTTP requests.", e);
		}
		// ensure the expected redirect behavior
		connection.setInstanceFollowRedirects(false);
		// set the request method
		connection.setDoOutput(request.method().supportsRequestPayload());
		connection.setRequestMethod(request.method().verb());
		// add all headers
		for (Header<?> header : request.headers())
		{
			connection.setRequestProperty(header.type().name(), header.toString());
		}
		// also set the content-type header if we have any content-type
		if (request.requestEntity().contentType() != null)
		{
			connection.setRequestProperty(HttpHeaders.CONTENT_TYPE.name(), HttpHeaders.CONTENT_TYPE.valueString(request.requestEntity().contentType()));
		}
		// send the request entity if applicable
		if (request.method().supportsRequestPayload())
		{
			OutputStream out = connection.getOutputStream();
			try
			{
				request.requestEntity().writeContent(out);
			}
			finally
			{
				out.close();
			}
		}
		// return the response
		return new HttpUrlConnectionResponse(uri, connection);
	}
326968
protected function response($data, $code = 200, $type = "json")
    {
        $this->http_status($code);
        Util::rep_send($data, $type);
    }
1347019
protected function redirect ($url, $code = 301) {
		$app = \MvcCore\Application::GetInstance();
		$app->GetResponse()
			->SetCode($code)
			->SetHeader('Location', $url);
		$app->Terminate();
	}
1118558
protected function redirect(string $uri, int $statusCode = 302) : Response
    {
        return (new Response())
            ->setStatusCode($statusCode)
            ->setHeader('Location', $uri);
    }
1081260
public function redirect($url, $code = 303)
    {
        $this->respondWith($code);
        $this->setResponseHeader('Location', $url);
        
        $urlHtml = htmlentities($url);
        $this->output('You are being redirected to <a href="' . $urlHtml . '">' . $urlHtml . '</a>', 'text/html');
    }
1056655
protected function redirectTo($uri = '', $type = 'location', $httpResponseCode = 302) : AbstractBaseController
    {
        $container = $this->container();
        if ($container->has('url')) {
            $container->get('url')->redirectTo($uri, $type, $httpResponseCode);
        }

        return $this;
    }
369201
protected function redirect(string $url, array $parameters = [], int $httpResponseCode = 307)
    {
        $query = '';
        // Making URL query string if parameters given.
        if (!empty($parameters)) {
            $query = '?';
            if (parse_url($url, PHP_URL_QUERY)) {
                $query = '&';
            }
            $query .= http_build_query($parameters);
        }

        header('Location: ' . $url . $query, true, $httpResponseCode);
        exit;
    }
735138
protected function findRedirectLinkInHeader(&$http_header)
  {
    PHPCrawlerBenchmark::start("checking_for_redirect_link");
    
    // Get redirect-URL or link from header
    $redirect_link = PHPCrawlerUtils::getRedirectURLFromHeader($http_header);
    
    // Add redirect-URL to linkcache
    if ($redirect_link != null)
    {
      $this->addLinkToCache($redirect_link, "", "", true);
    }
    
    PHPCrawlerBenchmark::stop("checking_for_redirect_link");
  }
112181
public function redirect($url, $header=301)
    {
        $this->disableLayout();
        $this->setNoRender();

        $this->_params["dispatcher"]->clearHeaders();
        $this->_params["dispatcher"]->addHeader("Location", $url, $header);
    }
145906
public static function token(String $uri = NULL, String $type = 'post')
    {
        Security::CSRFToken($uri, $type);
    }
962907
protected function getRedirectResponse($type) {
    $sdk = $this->getSdk($type);

    if ($sdk instanceof RedirectResponse) {
      return $sdk;
    }

    $this->authManager->setSdk($sdk);
    $url = $this->authManager->getAuthenticationUrl($type);

    return new TrustedRedirectResponse($url);
  }
1087071
protected function redirect($source, array $parameters = array(), $code = 307)
    {
        if ($source instanceof Url) {
            $url = $source->toString();
        } elseif (filter_var($source, FILTER_VALIDATE_URL)) {
            $url = $source;
        } else {
            $url = $this->reverseRouter->getUrl($source, $parameters);
        }

        if ($code == 301) {
            throw new StatusCode\MovedPermanentlyException($url);
        } elseif ($code == 302) {
            throw new StatusCode\FoundException($url);
        } elseif ($code == 307) {
            throw new StatusCode\TemporaryRedirectException($url);
        } else {
            throw new RuntimeException('Invalid redirect status code');
        }
    }
369651
public function redirectTo($target, $headerCode = 301, $withOrigin = false)
    {
        if (!($this->request instanceof WebRequest)) {
            return;
        }
        
        if (!preg_match('/http(s?)\:\/\//', $target)) {
            $target = $this->request->getFullRoute($target);
        }
        
        if ($withOrigin) {
            $target = $this->addOriginToTargetUrl($target);
        }
        
        header("Location: " . $target, true, $headerCode);
    }
840047
public static function url($url, $code = 302, $headers = array())
    {
        $r = static::createRedirectResponse((string) $url, $code, $headers);

        return $r;
    }
948836
public function redirect($uri, int $statusCode = 302): self
    {
        $this->headers->location($uri);
        return $this->fixateCode($statusCode);
    }