本文整理匯總了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']);
}
}
}
示例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;
}