本文整理汇总了PHP中Buzz\Message\Request::setProtocolVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::setProtocolVersion方法的具体用法?PHP Request::setProtocolVersion怎么用?PHP Request::setProtocolVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Buzz\Message\Request
的用法示例。
在下文中一共展示了Request::setProtocolVersion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareRequest
/**
* @param Request $request
* @return BuzzRequest
*/
protected function prepareRequest(Request $request)
{
$buzzRequest = new BuzzRequest($request->getMethod(), $request->getUrl()->getResource(), $request->getUrl()->getHost());
$buzzRequest->setProtocolVersion($request->getProtocolVersion());
$buzzRequest->setHeaders(HeaderConverter::convertAssociativeToRaw($this->prepareHeaders($request)));
$buzzRequest->setContent($request->getContent());
return $buzzRequest;
}
示例2: createRequest
/**
* Converts a PSR request into a BuzzRequest request.
*
* @param RequestInterface $request
*
* @return BuzzRequest
*/
private function createRequest(RequestInterface $request)
{
$buzzRequest = new BuzzRequest();
$buzzRequest->setMethod($request->getMethod());
$buzzRequest->fromUrl($request->getUri()->__toString());
$buzzRequest->setProtocolVersion($request->getProtocolVersion());
$buzzRequest->setContent((string) $request->getBody());
$this->addPsrHeadersToBuzzRequest($request, $buzzRequest);
return $buzzRequest;
}
示例3: __construct
public function __construct(Response $response, Request $request, Curl $client)
{
$this->response = $response;
$request->setProtocolVersion(1.1);
$request->addHeader('Content-Type: application/json');
$this->request = $request;
$client->setTimeout(5);
$client->setIgnoreErrors(true);
$this->client = $client;
}
示例4: testToStringFormatsTheRequest
public function testToStringFormatsTheRequest()
{
$request = new Request('POST', '/resource/123', 'http://example.com');
$request->setProtocolVersion(1.1);
$request->addHeader('Content-Type: application/x-www-form-urlencoded');
$request->setContent('foo=bar&bar=baz');
$expected = "POST /resource/123 HTTP/1.1\r\n";
$expected .= "Host: http://example.com\r\n";
$expected .= "Content-Type: application/x-www-form-urlencoded\r\n";
$expected .= "\r\n";
$expected .= "foo=bar&bar=baz\r\n";
$this->assertEquals($expected, (string) $request);
}
示例5: testDigestAuthHeader
public function testDigestAuthHeader()
{
$request = new Message\Request();
$request->setMethod('GET');
$request->setResource('/auth-digest');
$request->setHost('http://test.webdav.org');
$request->setProtocolVersion('1.1');
$response = new Message\Response();
$response->setHeaders(array("Date: Wed, 24 Jun 2015 21:49:39 GMT", "Server: Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.3.2", "WWW-Authenticate: Digest realm=\"test\", nonce=\"5PvRe0oZBQA=874ad6aea3519069f30dfc704e594dde6e01b2a6\", algorithm=MD5, domain=\"/auth-digest/\", qop=\"auth\"", "Content-Length: 401", "Content-Type: text/html; charset=iso-8859-1"));
$response->setContent("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>401 Authorization Required</title>\n</head><body>\n<h1>Authorization Required</h1>\n<p>This server could not verify that you\nare authorized to access the document\nrequested. Either you supplied the wrong\ncredentials (e.g., bad password), or your\nbrowser doesn\\'t understand how to supply\nthe credentials required.</p>\n</body></html>");
// Simulate the First Request/Response, where the server returns 401
$listener = new DigestAuthListener('user1', 'user1');
$listener->preSend($request);
$listener->postSend($request, $response);
// Simulate sending the second Request using the calculated Authorization Header
$request = new Message\Request();
$request->setMethod('GET');
$request->setResource('/auth-digest');
$request->setHost('http://test.webdav.org');
$request->setProtocolVersion('1.1');
$this->assertEmpty($request->getHeader('Authorization'));
$listener->preSend($request);
$this->assertEquals('Digest username="user1", realm="test", nonce="5PvRe0oZBQA=874ad6aea3519069f30dfc704e594dde6e01b2a6", response="b2cf05a5d3f51d84a8866309aed6cb5d", uri="/auth-digest"', $request->getHeader('Authorization'));
}