remove() public method

public remove ( $key )
示例#1
0
 /**
  * Check if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9
  *
  * @link http://support.microsoft.com/kb/323308
  */
 protected function ensureIEOverSSLCompatibility(Request $request)
 {
     if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
         if (intval(preg_replace("/(MSIE )(.*?);/", "\$2", $match[0])) < 9) {
             $this->headers->remove('Cache-Control');
         }
     }
 }
示例#2
0
文件: Response.php 项目: hykz/Depot
 /**
  * Modifies the response so that it conforms to the rules defined for a 304 status code.
  *
  * This sets the status, removes the body, and discards any headers
  * that MUST NOT be included in 304 responses.
  *
  * @see http://tools.ietf.org/html/rfc2616#section-10.3.5
  *
  * @api
  */
 public function setNotModified()
 {
     $this->setStatusCode(304);
     $this->setContent(null);
     // remove headers that MUST NOT be included with 304 Not Modified responses
     foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) {
         $this->headers->remove($header);
     }
 }
 public function testReplaceWithRemove()
 {
     $bag = new ResponseHeaderBag(array());
     $this->assertEquals('no-cache', $bag->get('Cache-Control'));
     $this->assertTrue($bag->hasCacheControlDirective('no-cache'));
     $bag->remove('Cache-Control');
     $bag->replace(array());
     $this->assertEquals('no-cache', $bag->get('Cache-Control'));
     $this->assertTrue($bag->hasCacheControlDirective('no-cache'));
 }
示例#4
0
    public function testSetCookieHeader()
    {
        $bag = new ResponseHeaderBag();
        $bag->set('set-cookie', 'foo=bar');
        $this->assertEquals(array(new Cookie('foo', 'bar', 0, '/', null, false, true, true)), $bag->getCookies());

        $bag->set('set-cookie', 'foo2=bar2', false);
        $this->assertEquals(array(
            new Cookie('foo', 'bar', 0, '/', null, false, true, true),
            new Cookie('foo2', 'bar2', 0, '/', null, false, true, true),
        ), $bag->getCookies());

        $bag->remove('set-cookie');
        $this->assertEquals(array(), $bag->getCookies());
    }