/** * Sends the specified HTTP status immediately. * * NOTE: This method only supports web requests and will throw an exception if used with other request types. * * @param integer $statusCode The HTTP status code * @param string $statusMessage A custom HTTP status message * @param string $content Body content which further explains the status * @throws \TYPO3\FLOW3\Mvc\Exception\UnsupportedRequestTypeException If the request is not a web request * @throws \TYPO3\FLOW3\Mvc\Exception\StopActionException * @api */ protected function throwStatus($statusCode, $statusMessage = NULL, $content = NULL) { $this->response->setStatus($statusCode, $statusMessage); if ($content === NULL) { $content = $this->response->getStatus(); } $this->response->setContent($content); throw new \TYPO3\FLOW3\Mvc\Exception\StopActionException(); }
/** * Starts the authentication: Redirect to login page * * @param \TYPO3\FLOW3\Http\Request $request The current request * @param \TYPO3\FLOW3\Http\Response $response The current response * @return void * @throws \TYPO3\FLOW3\Security\Exception\RequestTypeNotSupportedException * @throws \TYPO3\FLOW3\Security\Exception\MissingConfigurationException */ public function startAuthentication(Request $request, Response $response) { if (!isset($this->options['uri'])) { throw new \TYPO3\FLOW3\Security\Exception\MissingConfigurationException('The configuration for the WebRedirect authentication entry point is incorrect or missing.', 1237282583); } $plainUri = strpos('://', $this->options['uri'] !== FALSE) ? $this->options['uri'] : $request->getBaseUri() . $this->options['uri']; $escapedUri = htmlentities($plainUri, ENT_QUOTES, 'utf-8'); $response->setContent('<html><head><meta http-equiv="refresh" content="0;url=' . $escapedUri . '"/></head></html>'); $response->setStatus(303); $response->setHeader('Location', $plainUri); }
/** * Starts the authentication: Send HTTP header * * @param \TYPO3\FLOW3\Http\Request $request The current request * @param \TYPO3\FLOW3\Http\Response $response The current response * @return void * @throws \TYPO3\FLOW3\Security\Exception\RequestTypeNotSupportedException */ public function startAuthentication(Request $request, Response $response) { $response->setStatus(401); $response->setHeader('WWW-Authenticate', 'Basic realm="' . (isset($this->options['realm']) ? $this->options['realm'] : sha1(FLOW3_PATH_ROOT)) . '"'); $response->setContent('Authorization required'); }
/** * RFC 2616 / 4.3 (Message Body) * * 10.1.1 (100 Continue) * 10.1.2 (101 Switching Protocols) * 10.2.5 (204 No Content) * 10.3.5 (304 Not Modified) * * @test */ public function makeStandardsCompliantRemovesBodyContentIfStatusCodeImpliesIt() { $request = Request::create(new Uri('http://localhost')); $response = new Response(); foreach (array(100, 101, 204, 304) as $statusCode) { $response->setStatus($statusCode); $response->setContent('Body Language'); $response->makeStandardsCompliant($request); $this->assertEquals('', $response->getContent()); } }