當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::removeHeader方法代碼示例

本文整理匯總了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));
 }
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:13,代碼來源:Md5ValidatorPluginTest.php

示例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);
     }
 }
開發者ID:KANU82,項目名稱:guzzle,代碼行數:21,代碼來源:DefaultCacheStorage.php

示例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);
     }
 }
開發者ID:creazy412,項目名稱:vmware-win10-c65-drupal7,代碼行數:19,代碼來源:DefaultCacheStorage.php

示例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;
 }
開發者ID:norv,項目名稱:guzzle,代碼行數:30,代碼來源:CachePlugin.php

示例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());
 }
開發者ID:KANU82,項目名稱:guzzle,代碼行數:14,代碼來源:ResponseTest.php


注:本文中的Guzzle\Http\Message\Response::removeHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。