Setup HTTP redirect.

@param string $url
@param int $statusCode Optional
@return self
321096
public function redirect($url, $statusCode = 302) {
		$this->setStatusCode($statusCode)
			->setHeader('Location', $url)
			->setBody(sprintf('<!DOCTYPE html>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=%1$s">
<title>Redirecting to %1$s</title>
Redirecting to <a href="%1$s">%1$s</a>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')));

		return $this;
	}
221002
public function redirect($url, $status = 302)
    {
        $this->_headers['Location'] = (string) $url;
        $this->_status = (integer) $status;

        return $this;
    }
261318
public function redirect($location, $statusCode = 302) {
        $this->response->setHeader('Location', $location, true, $statusCode);
        return $this;
    }
410860
public static function isSuccessful(int $statusCode): bool
    {
        return ($statusCode >= HttpStatus::SUCCESSFUL) && ($statusCode < HttpStatus::REDIRECTION);
    }
479111
public function setStatus(int $statusCode):ResponseBuilder
    {
        if ($statusCode < 400 || $statusCode >= 600) {
            throw new InvalidArgumentException("{$statusCode} is not a valid error HTTP status code.");
        }
        return parent::setStatus($statusCode);
    }
929805
protected function newResponse(string $content, int $statusCode = null): HttpResponseInterface {
		
		if (is_null($statusCode)) {
			$statusCode = $this->type === "redirect" ? 302 : 200;
		}
		
		switch ($this->type) {
			case "json":
				return $this->responseFactory->newJsonResponse($content, $statusCode);
			
			case "text":
				return $this->responseFactory->newTextResponse($content, $statusCode);
			
			case "redirect":
				return $this->responseFactory->newRedirectResponse($content, $statusCode);
			
			default:
				return $this->responseFactory->newHtmlResponse($content, $statusCode);
		}
	}
518029
public function setStatus(int $statusCode): Response
	{
		if(isset($this->statusCodes[$statusCode]))
		{
			$this->statusCode = $statusCode;
		}

		return $this;
	}
558635
public function withRedirect($url, $status = null)
        {
            $response = $this->withHeader('Location', (string)$url);
            if (is_null($status) && $this->getStatusCode() === 200) {
                $status = 302;
            }
            if (!is_null($status)) {
                return $response->withStatus($status);
            }
            return $response;
        }
870978
protected function redirect($url, $code = 302)
    {
        if (!headers_sent()) {
            if (SERVER_MODE === 'swoole' ) {
                $GLOBALS['__$response']->status($code);
            } else if ($code == 301) {
                header('HTTP/1.1 301 Moved Permanently');
            } else {
                header('HTTP/1.1 302 Found');
            }

            $this->setHeader("Location", $url);
            $this->stopRun();
        } else {
            echo '<html><head><meta charset="UTF-8" /><title></title></head><body>';
            echo '<script>window.location.href="'. $url .'";</script></body></html>';
            $this->stopRun();
        }
    }
301625
public static function redirect(string $url, $httpResponseCodeParam = null)
    {
        if ($httpResponseCodeParam) {
            if (array_key_exists($httpResponseCodeParam, self::STATUS_CODE)) {
                $httpResponseCode = $httpResponseCodeParam;

                header('Location: '.$url, true, $httpResponseCode);
            } else {
                getException('Status code "'.$httpResponseCodeParam.'" not good.');
                
                header('Location: '.$url);
            }
        } else {
            header('Location: '.$url);
        }
        
        exit();
    }
217167
public function setStatus(int $statusCode): void
    {
        if (!isset($this->statusMessages[$statusCode])) {
            throw new \InvalidArgumentException('Invalid HTTP status code.');
        }
        $this->statusCode = $statusCode;
    }
1022885
protected function redirect($location = null, $statusCode = 302)
    {
        return $this->response->redirect(url($location), true, $statusCode);
    }
1207929
public function setRedirectUri(UriInterface $uri, int $statusCode = 303): void
    {
        $this->redirectUri = $uri;
        $this->statusCode = $statusCode;
        // TODO: This can be removed after the full changes are done for next major.
        $this->headers->set('Location', (string)$uri, true);
        $this->setStatusCode($statusCode);
    }
949529
protected function setProtocol($statuscode)
    {
    	if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' || $statuscode == Response::SC_CONTINUE || $statuscode == Response::SC_SWITCHING_PROTOCOLS || $statuscode == Response::SC_TEMPORARY_REDIRECT) {
        	header('HTTP/1.1 ' . $statuscode);
        } elseif (empty($_SERVER['SERVER_PROTOCOL'])) {
    		header('HTTP/1.0 ' . $statuscode);
    	} else {
    		header($_SERVER['SERVER_PROTOCOL'] . ' ' . $statuscode);
    	}
    }
518229
public function redirect($url, array $params = [], $status = 302)
    {
        if (!empty($params)) {
            $url = rtrim(preg_replace('/\?.*/', '', $url), '/');
            $url .= "?" . http_build_query($params);
        }

        $this->statusCode = $status;
        $this->headers->set('Location', $url);

        $this->getMbAudit()->setResponseType('redirect');
        $this->getMbAudit()->setResponseData([
            'url' => $url,
        ]);

        return true;
    }
1305706
public function sendRedirect($location, $status = 302)
    {
        if (!is_int($status) || $status < 300 || $status > 399) {
            return;
        }
        
        if ($location[0] != '/' && !preg_match("/^[0-9a-z]+:\\/\\//i", $location)) {
            $location = $this->baseUrl . $location;
        }
        
        $this->clearHeaders();
        $this->addHeader('Location', $location, true);
        $this->setStatus($status);
        $this->isRedirect = true;
        $this->sendHeaders();
        
        exit();
    }
937599
public function redirect($url, $code = 302)
    {
        $url = Director::absoluteURL($url);
        $response = new HTTPResponse();
        return $response->redirect($url, $code);
    }