本文整理汇总了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;
}