當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ResponseInterface::getProtocolVersion方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\ResponseInterface::getProtocolVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResponseInterface::getProtocolVersion方法的具體用法?PHP ResponseInterface::getProtocolVersion怎麽用?PHP ResponseInterface::getProtocolVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\ResponseInterface的用法示例。


在下文中一共展示了ResponseInterface::getProtocolVersion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendStatus

 /**
  * Send the status
  *
  * @param   ResponseInterface $response The response object
  *
  * @return  void
  */
 protected function sendStatus(ResponseInterface $response)
 {
     $version = $response->getProtocolVersion();
     $status = $response->getStatusCode();
     $phrase = $response->getReasonPhrase();
     header("HTTP/{$version} {$status} {$phrase}");
 }
開發者ID:nibra,項目名稱:joomla-pythagoras,代碼行數:14,代碼來源:ResponseSenderMiddleware.php

示例2: save

 /**
  * Save data
  *
  * @author  Florian Preusner
  * @version 2.1
  * @since   2015-05
  *
  * @param   ResponseInterface $response
  */
 public function save(ResponseInterface $response)
 {
     $this->setStatusCode($response->getStatusCode());
     $this->setStatusPhrase($response->getReasonPhrase());
     $this->setBody($response->getBody()->__toString());
     $this->setHeaders($response->getHeaders());
     $this->setProtocolVersion($response->getProtocolVersion());
 }
開發者ID:asprega,項目名稱:GuzzleBundle,代碼行數:17,代碼來源:LogResponse.php

示例3: formatResponse

 /**
  * {@inheritdoc}
  */
 public function formatResponse(ResponseInterface $response)
 {
     $message = sprintf("HTTP/%s %s %s\n", $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase());
     foreach ($response->getHeaders() as $name => $values) {
         $message .= $name . ': ' . implode(', ', $values) . "\n";
     }
     return $this->addBody($response, $message);
 }
開發者ID:php-http,項目名稱:message,代碼行數:11,代碼來源:FullHttpMessageFormatter.php

示例4: send

 /**
  * @param ResponseInterface $response
  */
 public function send(ResponseInterface $response)
 {
     header('HTTP/' . $response->getProtocolVersion() . ' ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase());
     foreach ($response->getHeaders() as $header => $values) {
         header($header . ': ' . implode(', ', $values));
     }
     parent::send($response);
 }
開發者ID:linpax,項目名稱:microphp-framework,代碼行數:11,代碼來源:MvcApplication.php

示例5: sendHeaders

 /**
  * Sends the response headers.
  *
  * @param \Psr\Http\Message\ResponseInterface $response Response instance
  */
 private function sendHeaders(ResponseInterface $response)
 {
     $statusCode = $response->getStatusCode();
     header(sprintf('HTTP/%s %d %s', $response->getProtocolVersion(), $statusCode, $response->getReasonPhrase()), true, $statusCode);
     foreach ($response->getHeaders() as $name => $values) {
         foreach ($values as $value) {
             header("{$name}: {$value}", false, $statusCode);
         }
     }
 }
開發者ID:elegantweb,項目名稱:framework,代碼行數:15,代碼來源:Server.php

示例6: emitStatusLine

 /**
  * Emit the status line.
  *
  * Emits the status line using the protocol version and status code from
  * the response; if a reason phrase is availble, it, too, is emitted.
  *
  * @param ResponseInterface $response
  */
 private function emitStatusLine(ResponseInterface $response)
 {
     $reasonPhrase = $response->getReasonPhrase();
     header(sprintf(
         'HTTP/%s %d%s',
         $response->getProtocolVersion(),
         $response->getStatusCode(),
         ($reasonPhrase ? ' ' . $reasonPhrase : '')
     ));
 }
開發者ID:nwdrupal,項目名稱:nwdrupalwebsite,代碼行數:18,代碼來源:SapiEmitterTrait.php

示例7: getStatusLine

 private function getStatusLine(ResponseInterface $response)
 {
     $protocol = $response->getProtocolVersion();
     $statusCode = $response->getStatusCode();
     $reasonPhrase = $response->getReasonPhrase();
     if ($reasonPhrase) {
         return "HTTP/{$protocol} {$statusCode} {$reasonPhrase}";
     } else {
         return "HTTP/{$protocol} {$statusCode}";
     }
 }
開發者ID:pjdietz,項目名稱:wellrested,代碼行數:11,代碼來源:Transmitter.php

示例8: execute

 /**
  * Process a ResponseInterface into an output.
  *
  * @param ResponseInterface $httpResponse
  */
 public function execute(ResponseInterface $httpResponse)
 {
     $headerFunction = $this->headerFunction;
     $bodyFunction = $this->bodyFunction;
     $headerFunction('HTTP/' . $httpResponse->getProtocolVersion() . ' ' . $httpResponse->getStatusCode() . ' ' . $httpResponse->getReasonPhrase());
     foreach ($httpResponse->getHeaders() as $name => $values) {
         foreach ($values as $value) {
             $headerFunction(sprintf('%s: %s', $name, $value));
         }
     }
     $bodyFunction($httpResponse->getBody());
 }
開發者ID:opsbears,項目名稱:piccolo-web-io-standard,代碼行數:17,代碼來源:StandardOutputProcessor.php

示例9: sendResponse

 public static function sendResponse(Response $response)
 {
     header(sprintf('HTTP/%s %s %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()));
     foreach ($response->getHeaders() as $name => $values) {
         foreach ($values as $value) {
             header(sprintf('%s: %s', $name, $value), false);
         }
     }
     if (!in_array($response->getStatusCode(), [204, 205, 304])) {
         echo $response->getBody();
     }
 }
開發者ID:sasezaki,項目名稱:karen,代碼行數:12,代碼來源:Controller.php

示例10: toString

 /**
  * Create a string representation of a response.
  *
  * @param ResponseInterface $response
  * @return string
  */
 public static function toString(ResponseInterface $response)
 {
     $reasonPhrase = $response->getReasonPhrase();
     $headers = self::serializeHeaders($response->getHeaders());
     $body = (string) $response->getBody();
     $format = 'HTTP/%s %d%s%s%s';
     if (!empty($headers)) {
         $headers = "\r\n" . $headers;
     }
     $headers .= "\r\n\r\n";
     return sprintf($format, $response->getProtocolVersion(), $response->getStatusCode(), $reasonPhrase ? ' ' . $reasonPhrase : '', $headers, $body);
 }
開發者ID:zendframework,項目名稱:zend-diactoros,代碼行數:18,代碼來源:Serializer.php

示例11: renderResponse

/**
 * Takes a PSR-7 Response and outputs all headers and body. This should be the
 * very last thing done in request processing.
 */
function renderResponse(ResponseInterface $response)
{
    // Send HTTP code
    header(sprintf("HTTP/%s %s %s", $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()));
    // Additional headers
    foreach ($response->getHeaders() as $key => $values) {
        foreach ($values as $value) {
            header(sprintf("%s: %s", $key, $value), false);
        }
    }
    // And then the body
    echo $response->getBody();
}
開發者ID:firehed,項目名稱:api,代碼行數:17,代碼來源:renderResponse.php

示例12: send

 public static function send(ResponseInterface $response)
 {
     $statusCode = $response->getStatusCode();
     $reasonPhrase = $response->getReasonPhrase();
     $protocolVersion = $response->getProtocolVersion();
     header("HTTP/{$protocolVersion} {$statusCode} {$reasonPhrase}");
     foreach ($response->getHeaders() as $name => $values) {
         foreach ($values as $value) {
             header(sprintf('%s: %s', $name, $value), false);
         }
     }
     echo $response->getBody();
 }
開發者ID:serendip811,項目名稱:patio42,代碼行數:13,代碼來源:ResponseSender.php

示例13: sendHeaders

 public function sendHeaders(ResponseInterface $response)
 {
     header(sprintf('HTTP/%s %s %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()), true, $response->getStatusCode());
     foreach ($response->getHeaders() as $header => $values) {
         $name = $this->filterHeader($header);
         $first = true;
         foreach ($values as $value) {
             header(sprintf('%s: %s', $name, $value), $first);
             $first = false;
         }
     }
     $time = round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], 3);
     header("X-Processing-Time: {$time} seconds");
 }
開發者ID:electro-framework,項目名稱:framework,代碼行數:14,代碼來源:ResponseSender.php

示例14: sendResponse

 /**
  * Sends the response back to the client
  *
  * @param ResponseInterface $response
  */
 public function sendResponse(ResponseInterface $response)
 {
     if (!headers_sent()) {
         $header = sprintf('HTTP/%s %s %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase());
         header($header);
         foreach ($response->getHeaders() as $name => $values) {
             foreach ($values as $value) {
                 $header = sprintf('%s: %s', $name, $value);
                 header($header, false);
             }
         }
     }
     echo (string) $response->getBody();
 }
開發者ID:alecgunnar,項目名稱:maverick,代碼行數:19,代碼來源:Application.php

示例15: send

function send(ResponseInterface $response)
{
    if (!headers_sent()) {
        // status
        header(sprintf('HTTP/%s %s %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()), true, $response->getStatusCode());
        // headers
        foreach ($response->getHeaders() as $header => $values) {
            foreach ($values as $value) {
                header($header . ': ' . $value, false, $response->getStatusCode());
            }
        }
    }
    echo $response->getBody();
}
開發者ID:quimcalpe,項目名稱:psr7-response-sender,代碼行數:14,代碼來源:response_sender.php


注:本文中的Psr\Http\Message\ResponseInterface::getProtocolVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。