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


PHP Response::setHeader方法代码示例

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


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

示例1: redirectToUri

 /**
  * Redirects to another URI
  *
  * @param mixed $uri Either a string representation of a URI or a \TYPO3\Flow\Http\Uri object
  * @param integer $delay (optional) The delay in seconds. Default is no delay.
  * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other"
  * @throws \TYPO3\Flow\Mvc\Exception\UnsupportedRequestTypeException If the request is not a web request
  * @throws \TYPO3\Flow\Mvc\Exception\StopActionException
  * @api
  */
 protected function redirectToUri($uri, $delay = 0, $statusCode = 303)
 {
     $escapedUri = htmlentities($uri, ENT_QUOTES, 'utf-8');
     $this->response->setContent('<html><head><meta http-equiv="refresh" content="' . intval($delay) . ';url=' . $escapedUri . '"/></head></html>');
     $this->response->setStatus($statusCode);
     if ($delay === 0) {
         $this->response->setHeader('Location', (string) $uri);
     }
     throw new \TYPO3\Flow\Mvc\Exception\StopActionException();
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:20,代码来源: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: makeStandardsCompliantReturns412StatusIfUnmodifiedSinceDoesNotMatch

 /**
  * RFC 2616 / 14.28 (If-Unmodified-Since)
  *
  * @test
  */
 public function makeStandardsCompliantReturns412StatusIfUnmodifiedSinceDoesNotMatch()
 {
     $request = Request::create(new Uri('http://localhost'));
     $response = new Response();
     $unmodifiedSince = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 15 May 2012 09:00:00 GMT');
     $lastModified = \DateTime::createFromFormat(DATE_RFC2822, 'Sun, 20 May 2012 08:00:00 UTC');
     $request->setHeader('If-Unmodified-Since', $unmodifiedSince);
     $response->setHeader('Last-Modified', $lastModified);
     $response->makeStandardsCompliant($request);
     $this->assertSame(412, $response->getStatusCode());
     $response = new Response();
     $unmodifiedSince = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 15 May 2012 09:00:00 GMT');
     $lastModified = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 15 May 2012 08:00:00 UTC');
     $request->setHeader('If-Unmodified-Since', $unmodifiedSince);
     $response->setHeader('Last-Modified', $lastModified);
     $response->makeStandardsCompliant($request);
     $this->assertSame(200, $response->getStatusCode());
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:23,代码来源: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

示例9: serve

 /**
  * @param string $filePathAndName Absolute path to the file to serve
  * @param HttpResponse $httpResponse The current HTTP response (allows setting headers, ...)
  * @return void
  */
 public function serve($filePathAndName, HttpResponse $httpResponse)
 {
     $httpResponse->setHeader('X-Accel-Redirect', $filePathAndName);
 }
开发者ID:vixe76,项目名称:Wwwision.PrivateResources,代码行数:9,代码来源:XAccelRedirectStrategy.php


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