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


PHP ResponseInterface::getProtocolVersion方法代碼示例

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


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

示例1: createResponse

 private function createResponse(GuzzleResponse $response)
 {
     $body = $response->getBody();
     return new Response($response->getStatusCode(), $response->getHeaders(), isset($body) ? $body->detach() : null, $response->getProtocolVersion(), $response->getReasonPhrase());
 }
開發者ID:jsor,項目名稱:hal-client,代碼行數:5,代碼來源:Guzzle5HttpClient.php

示例2: createResponse

 /**
  * Converts a Guzzle response into a PSR response.
  *
  * @param GuzzleResponse $response
  *
  * @return ResponseInterface
  */
 private function createResponse(GuzzleResponse $response)
 {
     $body = $response->getBody();
     return $this->messageFactory->createResponse($response->getStatusCode(), null, $response->getHeaders(), isset($body) ? $body->detach() : null, $response->getProtocolVersion());
 }
開發者ID:parsingeye,項目名稱:guzzle5-adapter,代碼行數:12,代碼來源:Guzzle5HttpAdapter.php

示例3: getParameters

 /**
  * Get context fields to add to the time-line entry.
  *
  * @param RequestInterface  $request
  * @param ResponseInterface $response
  * @param Exception         $error
  *
  * @return array
  */
 protected function getParameters(RequestInterface $request, ResponseInterface $response = null, Exception $error = null)
 {
     $params = [];
     $keys = array_intersect($this->context, $this->availableParameters);
     foreach ($keys as $key) {
         switch ($key) {
             case 'request':
                 $result = $request;
                 break;
             case 'response':
                 $result = $response;
                 break;
             case 'method':
                 $result = $request->getMethod();
                 break;
             case 'url':
                 $result = $request->getUrl();
                 break;
             case 'resource':
                 $result = $request->getResource();
                 break;
             case 'request_version':
                 $result = $request->getProtocolVersion();
                 break;
             case 'response_version':
                 $result = $response ? $response->getProtocolVersion() : 'NULL';
                 break;
             case 'host':
                 $result = $request->getHost();
                 break;
             case 'hostname':
                 $result = gethostname();
                 break;
             case 'status_code':
                 $result = $response ? $response->getStatusCode() : 'NULL';
                 break;
             case 'phrase':
                 $result = $response ? $response->getReasonPhrase() : 'NULL';
                 break;
             case 'error':
                 $result = $error ? $error->getMessage() : 'NULL';
                 break;
         }
         $params[$key] = (string) $result ?: '';
     }
     return $params;
 }
開發者ID:jezzdk,項目名稱:guzzle-debugbar,代碼行數:56,代碼來源:DebugbarSubscriber.php

示例4: format

 /**
  * Returns a formatted message
  *
  * @param RequestInterface  $request    Request that was sent
  * @param ResponseInterface $response   Response that was received
  * @param \Exception        $error      Exception that was received
  * @param array             $customData Associative array of custom template data
  *
  * @return string
  */
 public function format(RequestInterface $request, ResponseInterface $response = null, \Exception $error = null, array $customData = array())
 {
     $cache = $customData;
     $that = $this;
     return preg_replace_callback('/{\\s*([A-Za-z_\\-\\.0-9]+)\\s*}/', function (array $matches) use($request, $response, $error, &$cache, $that) {
         if (isset($cache[$matches[1]])) {
             return $cache[$matches[1]];
         }
         $result = '';
         switch ($matches[1]) {
             case 'request':
                 $result = $request;
                 break;
             case 'response':
                 $result = $response;
                 break;
             case 'req_headers':
                 $result = trim($request->getMethod() . ' ' . $request->getResource()) . ' HTTP/' . $request->getProtocolVersion() . "\r\n" . $that->headers($request);
                 break;
             case 'res_headers':
                 $result = $response ? sprintf('HTTP/%s %d %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()) . "\r\n" . $that->headers($response) : 'NULL';
                 break;
             case 'req_body':
                 $result = $request->getBody();
                 break;
             case 'res_body':
                 $result = $response ? $response->getBody() : 'NULL';
                 break;
             case 'ts':
                 $result = gmdate('c');
                 break;
             case 'method':
                 $result = $request->getMethod();
                 break;
             case 'url':
                 $result = $request->getUrl();
                 break;
             case 'resource':
                 $result = $request->getResource();
                 break;
             case 'req_version':
                 $result = $request->getProtocolVersion();
                 break;
             case 'res_version':
                 $result = $response ? $response->getProtocolVersion() : 'NULL';
                 break;
             case 'host':
                 $result = $request->getHost();
                 break;
             case 'hostname':
                 $result = gethostname();
                 break;
             case 'code':
                 $result = $response ? $response->getStatusCode() : 'NULL';
                 break;
             case 'phrase':
                 $result = $response ? $response->getReasonPhrase() : 'NULL';
                 break;
             case 'error':
                 $result = $error ? $error->getMessage() : 'NULL';
                 break;
             default:
                 // handle prefixed dynamic headers
                 if (strpos($matches[1], 'req_header_') === 0) {
                     $result = $request->getHeader(substr($matches[1], 11));
                 } elseif (strpos($matches[1], 'res_header_') === 0) {
                     $result = $response ? $response->getHeader(substr($matches[1], 11)) : 'NULL';
                 }
         }
         $cache[$matches[1]] = $result;
         return $result;
     }, $this->template);
 }
開發者ID:bobozhangshao,項目名稱:HeartCare,代碼行數:83,代碼來源:Formatter.php

示例5: getResponseOptions

 /**
  * @param ResponseInterface $guzzleResponse
  * @return mixed
  */
 protected function getResponseOptions($guzzleResponse)
 {
     $options = [];
     $reasonPhrase = $guzzleResponse->getReasonPhrase();
     if (!empty($reasonPhrase)) {
         $options['reason_phrase'] = $reasonPhrase;
     }
     $protocolVersion = $guzzleResponse->getProtocolVersion();
     if (!empty($protocolVersion)) {
         $options['protocol_version'] = $protocolVersion;
         return $options;
     }
     return $options;
 }
開發者ID:alec-ascotgroup,項目名稱:sendgrid-webapi-v3-php,代碼行數:18,代碼來源:HttpClient.php


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