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


PHP Response::setReasonPhrase方法代码示例

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


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

示例1: sendHandshakeResponse

 private function sendHandshakeResponse()
 {
     try {
         $challengeHeader = $this->getHandshakeRequest()->getHeader('Sec-Websocket-Key', null);
         if (!$challengeHeader) {
             throw new Exception("No Sec-WebSocket-Key received!");
         }
         // Check for newer handshake
         $challenge = $challengeHeader->getFieldValue();
         // Build response
         $response = new Response();
         $response->setStatusCode(101);
         $response->setReasonPhrase("WebSocket Protocol Handshake");
         $headers = new Headers();
         $response->setHeaders($headers);
         $headers->addHeaderLine("Upgrade", "WebSocket");
         $headers->addHeaderLine("Connection", "Upgrade");
         $headers->addHeaderLine("Sec-WebSocket-Accept", self::calcHybiResponse($challenge));
         $this->setResponse($response);
         $handshakeRequest = new Handshake($this->getHandshakeRequest(), $this->getHandshakeResponse());
         $this->emit("handshake", array($handshakeRequest));
         if ($handshakeRequest->isAborted()) {
             $this->close();
         } else {
             $this->_socket->write($response->toString());
             $this->logger->debug("Got an HYBI style request, sent HYBY handshake response");
             $this->connected = true;
             $this->emit("connect");
         }
     } catch (Exception $e) {
         $this->logger->err("Connection error, message: " . $e->getMessage());
         $this->close();
     }
 }
开发者ID:rb-cohen,项目名称:phpws,代码行数:34,代码来源:WebSocketTransportHybi.php

示例2: testResponseCanRenderStatusLine

 public function testResponseCanRenderStatusLine()
 {
     $response = new Response();
     $response->setVersion(1.1);
     $response->setStatusCode(Response::STATUS_CODE_404);
     $this->assertEquals('HTTP/1.1 404 Not Found', $response->renderStatusLine());
     $response->setReasonPhrase('Foo Bar');
     $this->assertEquals('HTTP/1.1 404 Foo Bar', $response->renderStatusLine());
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:9,代码来源:ResponseTest.php

示例3: sendHandshakeResponse

 private function sendHandshakeResponse()
 {
     // Last 8 bytes of the client's handshake are used for key calculation later
     $l8b = $this->request->getContent();
     // Check for 2-key based handshake (Hixie protocol draft)
     $key1 = $this->getHandshakeRequest()->getHeader('Sec-Websocket-Key1')->getFieldValue();
     $key2 = $this->getHandshakeRequest()->getHeader('Sec-Websocket-Key2')->getFieldValue();
     // Origin checking (TODO)
     $originHeader = $this->getHandshakeRequest()->getHeader('Origin', null);
     $host = $this->getHandshakeRequest()->getHeader('Host')->getFieldValue();
     $location = $this->getHandshakeRequest()->getUriString();
     // Build response
     $response = new Response();
     $response->setStatusCode(101);
     $response->setReasonPhrase("WebSocket Protocol Handshake");
     $headers = new Headers();
     $response->setHeaders($headers);
     $headers->addHeaderLine("Upgrade", "WebSocket");
     $headers->addHeaderLine("Connection", "Upgrade");
     if ($originHeader) {
         $headers->addHeaderLine("Sec-WebSocket-Origin", $originHeader->getFieldValue());
     }
     $headers->addHeaderLine("Sec-WebSocket-Location", "ws://{$host}{$location}");
     // Build HIXIE response
     $response->setContent(self::calcHixieResponse($key1, $key2, $l8b));
     $this->setResponse($response);
     $handshakeRequest = new Handshake($this->getHandshakeRequest(), $this->getHandshakeResponse());
     $this->emit("handshake", [$handshakeRequest]);
     if ($handshakeRequest->isAborted()) {
         $this->close();
     } else {
         $this->socket->write($response->toString());
         $this->logger->debug("Got an HYBI style request, sent HYBY handshake response");
         $this->emit("connect");
     }
 }
开发者ID:valinurovam,项目名称:phpws,代码行数:36,代码来源:WebSocketTransportHixie.php

示例4: prepareResponse

 /**
  * {@inheritDoc}
  */
 public function prepareResponse(HttpResponse $response)
 {
     $response->setStatusCode($this->getCode());
     $response->setReasonPhrase($this->getMessage());
 }
开发者ID:omusico,项目名称:zfr-rest,代码行数:8,代码来源:AbstractHttpException.php

示例5: getResponse

 /**
  * Retrieve response by version and name
  *
  * @param string $version version
  * @param string $name    name
  * @param boolean $validity    validity
  *
  * @throws RuntimeException
  * @return \Zend\Http\Response
  */
 protected function getResponse($version, $name, $validity = true)
 {
     // 	    $file = realpath(
     // 	            \VUFIND_PHPUNIT_MODULE_PATH . self::FIXTURE_DIRECTORY . 'responses/' .
     // 	            ($validity ? 'valid' : 'invalid') . '/' . $version . '/' . $name
     // 	    );
     $file = realpath(\VUFIND_PHPUNIT_MODULE_PATH . self::FIXTURE_DIRECTORY . 'responses/' . $version . '/' . $name);
     if (!$file) {
         throw new RuntimeException(sprintf('Unable to resolve fixture file: %s', $name));
     }
     $content = file_get_contents($file);
     $response = new Response();
     $response->setContent($content);
     $response->setStatusCode(Response::STATUS_CODE_200);
     $response->setReasonPhrase('OK');
     return $response;
 }
开发者ID:paulusova,项目名称:VuFind-2.x,代码行数:27,代码来源:XCNCIP2Test.php

示例6: withStatus

 /**
  * withStatus
  *
  * @param int    $statusCode
  * @param string $reasonPhrase
  *
  * @return $this
  */
 public function withStatus($statusCode, $reasonPhrase = '')
 {
     parent::setStatusCode($statusCode);
     parent::setReasonPhrase($reasonPhrase);
     return $this;
 }
开发者ID:reliv,项目名称:rcm-api-lib,代码行数:14,代码来源:ApiResponse.php

示例7: convertToZfResponse

 /**
  * Convert a PSR-7 response to ZF2 response
  *
  * @param  ResponseInterface $response
  * @return HttpResponse
  */
 private function convertToZfResponse(ResponseInterface $response)
 {
     $zfResponse = new HttpResponse();
     $zfResponse->setStatusCode($response->getStatusCode());
     $zfResponse->setReasonPhrase($response->getReasonPhrase());
     $zfResponse->setContent((string) $response->getBody());
     foreach ($response->getHeaders() as $name => $values) {
         $zfResponse->getHeaders()->addHeaderLine($name, implode(", ", $values));
     }
     return $zfResponse;
 }
开发者ID:basz,项目名称:zfr-oauth2-server-module,代码行数:17,代码来源:TokenController.php


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