Beispiel #1
0
 /**
  * This method is called when the session has been initialized (loaded or created).
  *
  * @return void
  *
  * @see YapepBase\Session.SessionAbstract::sessionInitialized()
  *
  * @todo move cache limiter to response&controller
  */
 protected function sessionInitialized()
 {
     parent::sessionInitialized();
     if ($this->cacheLimitersEnabled) {
         $this->response->addHeader('Expires', 'Thu, 19 Nov 1981 08:52:00 GMT');
         $this->response->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
         $this->response->addHeader('Pragma', 'no-cache');
     }
 }
Beispiel #2
0
 /**
  * Tests the correct handing of headers.
  */
 public function testHeaders()
 {
     $this->createCleanResponse();
     $this->assertEquals(false, $this->response->hasHeader('X-Test-Header'));
     $this->response->setHeader('X-Test-Header', 'Test Value');
     $this->assertEquals(true, $this->response->hasHeader('X-Test-Header'));
     $this->assertEquals(array('Test Value'), $this->response->getHeader('X-Test-Header'));
     $this->response->addHeader('X-Test-Header', 'Test Value 2');
     $this->assertEquals(array('Test Value', 'Test Value 2'), $this->response->getHeader('X-Test-Header'));
     $this->response->setHeader('X-Test-Header', 'Test Value 3');
     $this->assertEquals(array('Test Value 3'), $this->response->getHeader('X-Test-Header'));
     $this->response->removeHeader('X-Test-Header');
     $this->assertEquals(false, $this->response->hasHeader('X-Test-Header'));
     $this->createCleanResponse();
     $this->response->setHeader('X-Test-Header-2: Test : Value');
     $this->assertEquals(array('Test : Value'), $this->response->getHeader('X-Test-Header-2'));
     $this->createCleanResponse();
     $this->response->setHeader(array('X-Test-Header-3: Test : Value', 'X-Test-Header-4: Test : Value'));
     $this->assertEquals(array('Test : Value'), $this->response->getHeader('X-Test-Header-3'));
     $this->assertEquals(array('Test : Value'), $this->response->getHeader('X-Test-Header-4'));
     $this->createCleanResponse();
     $this->response->setHeader(array('X-Test-Header-3' => 'Test : Value', 'X-Test-Header-4' => 'Test : Value'));
     $this->assertEquals(array('Test : Value'), $this->response->getHeader('X-Test-Header-3'));
     $this->assertEquals(array('Test : Value'), $this->response->getHeader('X-Test-Header-4'));
     $this->createCleanResponse();
     try {
         $this->response->addHeader('This is an invalid setHeader line');
         $this->fail('Invalid setHeader lines are not caught!');
     } catch (\YapepBase\Exception\ParameterException $e) {
     }
     try {
         $this->response->addHeader('');
         $this->fail('Empty setHeader lines are not caught!');
     } catch (\YapepBase\Exception\ParameterException $e) {
     }
     try {
         $this->response->addHeader('X-Test-Header', '');
         $this->fail('Empty setHeader values are not caught!');
     } catch (\YapepBase\Exception\ParameterException $e) {
     }
     try {
         $this->response->getHeader('X-Non-Existent');
         $this->fail('Fetching non-existent headers should throw an IndexOutOfBoundsException');
     } catch (\YapepBase\Exception\IndexOutOfBoundsException $e) {
     }
 }