当前位置: 首页>>代码示例>>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;未经允许,请勿转载。