本文整理汇总了PHP中Guzzle\Http\Message\Response::removeHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::removeHeader方法的具体用法?PHP Response::removeHeader怎么用?PHP Response::removeHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Response
的用法示例。
在下文中一共展示了Response::removeHeader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValidatesMd5
public function testValidatesMd5()
{
$plugin = new Md5ValidatorPlugin();
$request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
$request->getEventDispatcher()->addSubscriber($plugin);
$body = 'abc';
$hash = md5($body);
$response = new Response(200, array('Content-MD5' => $hash, 'Content-Length' => 3), 'abc');
$request->dispatch('request.complete', array('response' => $response));
// Try again with no Content-MD5
$response->removeHeader('Content-MD5');
$request->dispatch('request.complete', array('response' => $response));
}
示例2: cache
/**
* {@inheritdoc}
*/
public function cache($key, Response $response, $ttl = null)
{
if ($ttl === null) {
$ttl = $this->defaultTtl;
}
if ($ttl) {
$response->setHeader('X-Guzzle-Cache', "key={$key}, ttl={$ttl}");
// Remove excluded headers from the response (see RFC 2616:13.5.1)
foreach ($this->excludeResponseHeaders as $header) {
$response->removeHeader($header);
}
// Add a Date header to the response if none is set (for validation)
if (!$response->getDate()) {
$response->setHeader('Date', Utils::getHttpDate('now'));
}
$this->cache->save($key, array($response->getStatusCode(), $response->getHeaders()->getAll(), $response->getBody(true)), $ttl);
}
}
示例3: cache
public function cache($key, Response $response, $ttl = null)
{
if ($ttl === null) {
$ttl = $this->defaultTtl;
}
$ttl += $response->getMaxAge();
if ($ttl) {
$response->setHeader('X-Guzzle-Cache', "key={$key}; ttl={$ttl}");
// Remove excluded headers from the response (see RFC 2616:13.5.1)
foreach ($this->excludeResponseHeaders as $header) {
$response->removeHeader($header);
}
// Add a Date header to the response if none is set (for validation)
if (!$response->getDate()) {
$response->setHeader('Date', gmdate(ClientInterface::HTTP_DATE));
}
$this->cache->save($key, array($response->getStatusCode(), $response->getHeaders()->toArray(), $response->getBody(true)), $ttl);
}
}
示例4: saveCache
/**
* Save data to the cache adapter
*
* @param string $key The cache key
* @param Response $response The response to cache
* @param int $lifetime Amount of seconds to cache
*
* @return int Returns the lifetime of the cached data
*/
protected function saveCache($key, Response $response, $lifetime = null)
{
$lifetime = $lifetime ?: $this->defaultLifetime;
// If the data is cacheable, then save it to the cache adapter
if ($lifetime) {
// Remove excluded headers from the response (see RFC 2616:13.5.1)
foreach ($this->excludeResponseHeaders as $header) {
$response->removeHeader($header);
}
// Add a Date header to the response if none is set (for validation)
if (!$response->getDate()) {
$response->setHeader('Date', Utils::getHttpDate('now'));
}
$data = array('c' => $response->getStatusCode(), 'h' => $response->getHeaders(), 'b' => $response->getBody(true));
if ($this->serialize) {
$data = serialize($data);
}
$this->getCacheAdapter()->save($key, $data, $lifetime);
}
return $lifetime;
}
示例5: testDeterminesIfItCanValidate
/**
* @covers Guzzle\Http\Message\Response::canValidate
*/
public function testDeterminesIfItCanValidate()
{
$response = new Response(200);
$this->assertFalse($response->canValidate());
$response->setHeader('ETag', '123');
$this->assertTrue($response->canValidate());
$response->removeHeader('ETag');
$this->assertFalse($response->canValidate());
$response->setHeader('Last-Modified', '123');
$this->assertTrue($response->canValidate());
}