当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::setStatus方法代码示例

本文整理汇总了PHP中TYPO3\Flow\Http\Response::setStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::setStatus方法的具体用法?PHP Response::setStatus怎么用?PHP Response::setStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\Flow\Http\Response的用法示例。


在下文中一共展示了Response::setStatus方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: throwStatus

 /**
  * 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\Flow\Mvc\Exception\UnsupportedRequestTypeException If the request is not a web request
  * @throws \TYPO3\Flow\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\Flow\Mvc\Exception\StopActionException();
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:21,代码来源:AbstractController.php

示例2: evaluate

 /**
  * Just return the processed value
  *
  * @return mixed
  */
 public function evaluate()
 {
     $httpResponse = new Response();
     $httpResponse->setStatus($this->getStatusCode());
     $httpResponse->setHeaders(new Headers());
     foreach ($this->getHeaders() as $name => $value) {
         $httpResponse->setHeader($name, $value);
     }
     return implode("\r\n", $httpResponse->renderHeaders()) . "\r\n\r\n";
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:15,代码来源:ResponseHeadImplementation.php

示例3: startAuthentication

 /**
  * Starts the authentication by redirecting to the SSO endpoint
  *
  * The redirect includes the callback URI (the original URI from the given request)
  * the client identifier and a signature of the arguments with the client private key.
  *
  * @param \TYPO3\Flow\Http\Request $request The current request
  * @param \TYPO3\Flow\Http\Response $response The current response
  * @return void
  */
 public function startAuthentication(Request $request, Response $response)
 {
     $callbackUri = $request->getUri();
     if (!isset($this->options['server'])) {
         throw new Exception('Missing "server" option for SingleSignOnRedirect entry point. Please specifiy one using the entryPointOptions setting.', 1351690358);
     }
     $ssoServer = $this->ssoServerFactory->create($this->options['server']);
     $ssoClient = $this->ssoClientFactory->create();
     $redirectUri = $ssoServer->buildAuthenticationEndpointUri($ssoClient, $callbackUri);
     $response->setStatus(303);
     $response->setHeader('Location', $redirectUri);
 }
开发者ID:anihy,项目名称:Flowpack.SingleSignOn.Client,代码行数:22,代码来源:SingleSignOnRedirect.php

示例4: startAuthentication

 /**
  * Starts the authentication: Redirect to login page
  *
  * @param \TYPO3\Flow\Http\Request $request The current request
  * @param \TYPO3\Flow\Http\Response $response The current response
  * @return void
  * @throws MissingConfigurationException
  */
 public function startAuthentication(Request $request, Response $response)
 {
     if (isset($this->options['routeValues'])) {
         $routeValues = $this->options['routeValues'];
         if (!is_array($routeValues)) {
             throw new MissingConfigurationException(sprintf('The configuration for the WebRedirect authentication entry point is incorrect. "routeValues" must be an array, got "%s".', gettype($routeValues)), 1345040415);
         }
         $actionRequest = new ActionRequest($request);
         $this->uriBuilder->setRequest($actionRequest);
         $actionName = $this->extractRouteValue($routeValues, '@action');
         $controllerName = $this->extractRouteValue($routeValues, '@controller');
         $packageKey = $this->extractRouteValue($routeValues, '@package');
         $subPackageKey = $this->extractRouteValue($routeValues, '@subpackage');
         $uri = $this->uriBuilder->setCreateAbsoluteUri(true)->uriFor($actionName, $routeValues, $controllerName, $packageKey, $subPackageKey);
     } elseif (isset($this->options['uri'])) {
         $uri = strpos($this->options['uri'], '://') !== false ? $this->options['uri'] : $request->getBaseUri() . $this->options['uri'];
     } else {
         throw new MissingConfigurationException('The configuration for the WebRedirect authentication entry point is incorrect or missing. You need to specify either the target "uri" or "routeValues".', 1237282583);
     }
     $response->setContent(sprintf('<html><head><meta http-equiv="refresh" content="0;url=%s"/></head></html>', htmlentities($uri, ENT_QUOTES, 'utf-8')));
     $response->setStatus(303);
     $response->setHeader('Location', $uri);
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:31,代码来源:WebRedirect.php

示例5: prepareErrorResponse

 /**
  * Prepare a response in case an error occurred.
  *
  * @param \Throwable $exception
  * @param Http\Response $response
  * @return void
  */
 protected function prepareErrorResponse($exception, Http\Response $response)
 {
     $pathPosition = strpos($exception->getFile(), 'Packages/');
     $filePathAndName = $pathPosition !== false ? substr($exception->getFile(), $pathPosition) : $exception->getFile();
     $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
     $content = PHP_EOL . 'Uncaught Exception in Flow ' . $exceptionCodeNumber . $exception->getMessage() . PHP_EOL;
     $content .= 'thrown in file ' . $filePathAndName . PHP_EOL;
     $content .= 'in line ' . $exception->getLine() . PHP_EOL . PHP_EOL;
     $content .= Debugger::getBacktraceCode($exception->getTrace(), false, true) . PHP_EOL;
     if ($exception instanceof Exception) {
         $statusCode = $exception->getStatusCode();
     } else {
         $statusCode = 500;
     }
     $response->setStatus($statusCode);
     $response->setContent($content);
     $response->setHeader('X-Flow-ExceptionCode', $exception->getCode());
     $response->setHeader('X-Flow-ExceptionMessage', $exception->getMessage());
 }
开发者ID:vjanoch,项目名称:flow-development-collection,代码行数:26,代码来源:InternalRequestEngine.php

示例6: browserHaltsOnExceedingMaximumRedirections

 /**
  * @test
  * @expectedException \TYPO3\Flow\Http\Client\InfiniteRedirectionException
  */
 public function browserHaltsOnExceedingMaximumRedirections()
 {
     $requestEngine = $this->getMock(\TYPO3\Flow\Http\Client\RequestEngineInterface::class);
     for ($i = 0; $i <= 10; $i++) {
         $response = new Response();
         $response->setHeader('Location', 'http://localhost/this/willLead/you/knowhere/' . $i);
         $response->setStatus(301);
         $requestEngine->expects($this->at($i))->method('sendRequest')->will($this->returnValue($response));
     }
     $this->browser->setRequestEngine($requestEngine);
     $this->browser->request('http://localhost/some/initialRequest');
 }
开发者ID:kszyma,项目名称:flow-development-collection,代码行数:16,代码来源:BrowserTest.php

示例7: makeStandardsCompliantRemovesBodyContentIfStatusCodeImpliesIt

 /**
  * 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());
     }
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:21,代码来源:ResponseTest.php

示例8: startAuthentication

 /**
  * Starts the authentication: Send HTTP header
  *
  * @param \TYPO3\Flow\Http\Request $request The current request
  * @param \TYPO3\Flow\Http\Response $response The current response
  * @return void
  */
 public function startAuthentication(Request $request, Response $response)
 {
     $response->setStatus(401);
     $response->setHeader('WWW-Authenticate', 'Basic realm="' . (isset($this->options['realm']) ? $this->options['realm'] : sha1(FLOW_PATH_ROOT)) . '"');
     $response->setContent('Authorization required');
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:13,代码来源:HttpBasic.php


注:本文中的TYPO3\Flow\Http\Response::setStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。