Send your visitor packing to another **$url** eg. after a form has been submitted.

@param string $url                Either the full url, or just the path.
@param int    $http_response_code The status code.

@example

```php
$page->eject('users');
```
4334
public function eject($url = '', $http_response_code = 302)
    {
        $url = (!empty($url)) ? $this->formatLocalPath($url) : $this->url['base'];

        return $this->send(RedirectResponse::create(htmlspecialchars_decode($url), $http_response_code));
    }
1072447
public static function httpRedirect($url, $code=NULL)
    {
        if ($code == 301) {
            header('HTTP/1.1 301 Moved Permanently');
        } else {
            header('HTTP/1.1 302 Moved Temporarily');
        }
        header('Location: ' . $url);
        die();
    }
1237482
public function setHttpCode($http_code) {
        if(!in_array($http_code, self::$VALID_HTTP))
            throw new \InvalidArgumentException('Invalid HTTP code');
        $this->http_code= $http_code;
    }
937599
public function redirect($url, $code = 302)
    {
        $url = Director::absoluteURL($url);
        $response = new HTTPResponse();
        return $response->redirect($url, $code);
    }
617274
function redirect(int $code, string $url): \Nofuzz\Http\HTTPResponse
  {
    $this->setStatusCode($code);
    $this->setHeader('Location',$url);
    $this->setBody('');

    return $this;
  }
145120
public static function get_http_response_code( $url ) {

		$curl = curl_init();
		curl_setopt_array(
			$curl,
			[
				CURLOPT_RETURNTRANSFER => true,
				CURLOPT_URL            => $url,
			]
		);
		curl_exec( $curl );
		$response_code = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
		curl_close( $curl );

		return $response_code;
	}
1015232
public function redirect($url, $code = 302)
    {
        if ($this->getResponse()->getHeader('Location') && $this->getResponse()->getHeader('Location') != $url) {
            user_error("Already directed to " . $this->getResponse()->getHeader('Location')
                . "; now trying to direct to $url", E_USER_WARNING);
            return null;
        }
        $response = parent::redirect($url, $code);
        $this->setResponse($response);
        return $response;
    }
479233
public function redirect($url, $statusCode = 302)
    {
        if (strpos($url, '/') === 0 && strpos($url, '//') !== 0) {
            $url = request()->root() . $url;
        }

        $this->status($statusCode);
        $this->headers->set('Location', $url);
    }
1018638
public function sendResponse()
  {
    # Set HTTP Response Code
    \http_response_code($this->getResponse()->getStatusCode());

    # Set All HTTP headers from Response Object
    foreach ($this->getResponse()->getHeaders() as $header => $value) {
      if (\is_array($value)) {
        $values = \implode(';',$value);
      } else {
        $values = $value;
      }

      \header($header.': '.$values);
    }

    # Remove the "x-powered-by" header set by PHP
    if (\function_exists('header_remove')) \header_remove('x-powered-by');

    # Set Cookies
    foreach ($this->cookies as $cookie)
    {
      \setCookie( $cookie['name'],
                  $cookie['value'],
                  $cookie['expire'] ?? 0,
                  $cookie['path'] ?? '',
                  $cookie['domain'] ?? '',
                  $cookie['secure'] ?? false,
                  $cookie['httponly'] ?? false
                );
    }

    ##
    ## Send a file or a body?
    ##
    if ( !empty($this->responseFile) ) {

      if (\file_exists($this->responseFile)) {
        # Debug log
        $this->getLogger()->debug('Sending file',[
          'code'=>$this->getResponse()->getStatusCode(),
          'headers'=>$this->getResponse()->getHeaders(),
          'file'=>$this->responseFile
        ]);

        # Send the file
        \readfile($this->responseFile);

      } else {
        # Log warning
        $this->getLogger()->warning('File not found',['file'=>$this->responseFile]);

        # Fake a response
        \response('',404);

        # Set HTTP Response Code
        \http_response_code(404);
      }

    } else {
      # Get body
      $body = (string)$this->response->getBody();

      # Debug log
      $this->getLogger()->debug('Sending body',[
        'code' => $this->getResponse()->getStatusCode(),
        'headers' => $this->getResponse()->getHeaders(),
        'size' => \strlen($body)
      ]);

      # Send the Body
      echo $body;
    }

    return $this;
  }
1029592
public function redirectTo( $url = 0, $code = 302 ) {
		if ( $url === null ) {
			$this->redirectTo = null;
			return true;
		}
		if ( !is_string( $url ) || !is_int( $code ) ) {
			return false;
		}
		$this->redirectTo = [ $url, $code ];
		return true;
	}
238412
public function sendHeader(string $name, ?string $value): void
    {
        if (headers_sent($file, $line)) {
            throw new HttpException(sprintf("Cannot use '%s()', headers already sent in %s:%s",
                __method__, $file, $line));
        }

        // null means remove
        if ($value === null) {
            $this->removeHeader($name);
            header_remove($name);
        } else {
            $this->setHeader($name, $value);
            header(sprintf('%s: %s', $name, $value));
        }
    }
1178774
protected function sendResponse($response, $http_code = 200)
    {
        $http_code = min(max($http_code, 100), 505);
        http_response_code($http_code);
        header('Content-type: application/json');
        echo json_encode($response);
    }
979766
public static function sendPost($_url, $_data, $_headers = [],
                                    $_return_header = true)
    {
        return self::sendCurl($_url,
                array(
                CURLOPT_SSL_VERIFYHOST => false,
                CURLOPT_SSL_VERIFYPEER => false,
                CURLOPT_FOLLOWLOCATION => 0,
                CURLOPT_POST => 1,
                CURLOPT_POSTFIELDS => $_data,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_HTTPHEADER => $_headers,
                CURLOPT_HEADER => $_return_header
        ));
    }
402383
public function redirect($url = null, $exitAfter = true)
    {
        if (empty($url)) {
            $url = $this->getRedirectUrl();
        }
        $this->_stateMgr->writeClose();
        if (session_id()) {
            session_write_close();
        }
        header("Location: $url");
        if ($exitAfter) {
            exit();
        }
    }
673520
public void sendRedirect(String url) 
        throws IOException
    {
        if (url==null)
            throw new IllegalArgumentException();
        
        if (!URI.hasScheme(url))
        {
            StringBuffer buf = _servletHttpRequest.getHttpRequest().getRootURL();
            if (url.startsWith("/"))
                buf.append(URI.canonicalPath(url));
            else
            {
                String path=_servletHttpRequest.getRequestURI();
                String parent=(path.endsWith("/"))?path:URI.parentPath(path);
                url=URI.canonicalPath(URI.addPaths(parent,url));
                if (!url.startsWith("/"))
                    buf.append('/');
                buf.append(url);
            }
            
            url=buf.toString();
        }
        
        resetBuffer();
        
        _httpResponse.setField(HttpFields.__Location,url);
        _httpResponse.setStatus(HttpResponse.__302_Moved_Temporarily);
        complete();
    }
625738
function send($url) {
             
            // Get xml document
            $strXML = $this->toString();
             
            // Get url parts
            if (!preg_match("/http/", $url)) $url = "http://".$url;
            $urlParts = parse_url($url);
            $host = isset($urlParts['host'])?$urlParts['host']:
            'localhost';
            $port = isset($urlParts['port'])?$urlParts['port']:
            80;
            $path = isset($urlParts['path'])?$urlParts['path']:"/";
             
            // Open a connection with the required host
            $fp = fsockopen($host, $port, $errno, $errstr);
            if (!$fp) {
                $this->status = -11;
                $this->error = "Unable to connect to $host at port $port: ($errno) $errstr";
                return false;
            }
             
            // Send the xml document
            fputs($fp, "POST ".$path." HTTP/1.0\r\n". "Host: ".$host."\r\n". "Content-length: ".strlen($strXML)."\r\n". "Content-type: ".$this->contentType."\r\n". "Connection: close\r\n\r\n". $strXML."\r\n");
             
            return $fp;
             
        }
1209689
public function send($url)
    {
        /** @var $response PageIndexerResponse */
        $response = GeneralUtility::makeInstance(PageIndexerResponse::class);
        $decodedResponse = $this->getUrlAndDecodeResponse($url, $response);

        if ($decodedResponse['requestId'] != $this->requestId) {
            throw new \RuntimeException(
                'Request ID mismatch. Request ID was ' . $this->requestId . ', received ' . $decodedResponse['requestId'] . '. Are requests cached?',
                1351260655
            );
        }

        $response->setRequestId($decodedResponse['requestId']);

        if (!is_array($decodedResponse['actionResults'])) {
            // nothing to parse
            return $response;
        }

        foreach ($decodedResponse['actionResults'] as $action => $actionResult) {
            $response->addActionResult($action, $actionResult);
        }

        return $response;
    }