本文整理匯總了PHP中Buzz\Message\Request::getHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getHeader方法的具體用法?PHP Request::getHeader怎麽用?PHP Request::getHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Buzz\Message\Request
的用法示例。
在下文中一共展示了Request::getHeader方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testBearerAuthListener
public function testBearerAuthListener()
{
$request = new Message\Request();
$this->assertEmpty($request->getHeader('Authorization'));
$listener = new BearerAuthListener('superSecretAccessTokenGeneratedByTheNsaItself');
$listener->preSend($request);
$this->assertEquals('Bearer superSecretAccessTokenGeneratedByTheNsaItself', $request->getHeader('Authorization'));
}
示例2: testBasicAuthHeader
public function testBasicAuthHeader()
{
$request = new Message\Request();
$this->assertEmpty($request->getHeader('Authorization'));
$listener = new BasicAuthListener('foo', 'bar');
$listener->preSend($request);
$this->assertEquals('Basic ' . base64_encode('foo:bar'), $request->getHeader('Authorization'));
}
示例3: isRequestCacheable
/**
*
* @param \Buzz\Message\Request $request
* @return boolean
*/
public function isRequestCacheable(Request $request)
{
if (!$this->isHTTPMethodCacheable($request->getMethod())) {
return false;
}
//[rfc2616-14.8]
if ($request->getHeader("authorization")) {
return false;
}
return true;
}
示例4: 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'));
}
示例5: getCanonicalHeaders
protected function getCanonicalHeaders(Request $request)
{
$headers = array_filter($this->headersToSign, function ($header) {
return false !== $request->getHeader($header);
});
$data = [];
foreach ($headers as $header) {
$data[strtolower($header)] = str_replace('/\\s+/', ' ', $request[$header]);
}
return implode('\\t', $data);
}