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


PHP RequestInterface::setProtocolVersion方法代碼示例

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


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

示例1: updateRequestFromTransfer

 /**
  * Update a request based on the log messages of the CurlHandle
  *
  * @param RequestInterface $request Request to update
  */
 public function updateRequestFromTransfer(RequestInterface $request)
 {
     if (!$request->getResponse()) {
         return;
     }
     // Update the transfer stats of the response
     $request->getResponse()->setInfo($this->getInfo());
     if (!($log = $this->getStderr(true))) {
         return;
     }
     // Parse the cURL stderr output for outgoing requests
     $headers = '';
     fseek($log, 0);
     while (($line = fgets($log)) !== false) {
         if ($line && $line[0] == '>') {
             $headers = substr(trim($line), 2) . "\r\n";
             while (($line = fgets($log)) !== false) {
                 if ($line[0] == '*' || $line[0] == '<') {
                     break;
                 } else {
                     $headers .= trim($line) . "\r\n";
                 }
             }
         }
     }
     // Add request headers to the request exactly as they were sent
     if ($headers) {
         $parsed = ParserRegistry::getInstance()->getParser('message')->parseRequest($headers);
         if (!empty($parsed['headers'])) {
             $request->setHeaders(array());
             foreach ($parsed['headers'] as $name => $value) {
                 $request->setHeader($name, $value);
             }
         }
         if (!empty($parsed['version'])) {
             $request->setProtocolVersion($parsed['version']);
         }
     }
 }
開發者ID:TechArea,項目名稱:core,代碼行數:44,代碼來源:CurlHandle.php

示例2: prepareRequest

 /**
  * prepareRequest
  *
  * @param \Guzzle\Http\Message\RequestInterface $request
  * @return RequestInterface
  */
 protected function prepareRequest(RequestInterface $request)
 {
     $request->setProtocolVersion($this->serviceProtocolVersion);
     $request->setHeader('Authorization', 'OAuth ' . $this->getAccessToken());
     $request->setHeader('Host', $this->getServiceDomain());
     $request->setHeader('User-Agent', $this->getUserAgent());
     $request->setHeader('Accept', '*/*');
     return $request;
 }
開發者ID:silverslice,項目名稱:yandex-php-library,代碼行數:15,代碼來源:AbstractServiceClient.php


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