예제 #1
0
파일: CCIn.php 프로젝트: clancats/core
 /**
  * Test input SERVER
  */
 public function testServer()
 {
     // generate server data
     $this->fakeServerData();
     // check server params
     $this->assertEquals(CCIn::server('server_port'), 80);
     // check server param default
     $this->assertEquals(CCIn::server('not_existing', 'test'), 'test');
     // check post param has
     $this->assertFalse(CCIn::has_server('not_existing'));
     // check post param has
     $this->assertTrue(CCIn::has_server('server_port'));
 }
예제 #2
0
 /**
  * send response
  * means printing the response and setting the headers if set
  *
  * @param bool		$headers	
  * @return  void
  */
 public function send($headers = false)
 {
     if ($headers && headers_sent() && !CLI) {
         throw new CCException("CCResponse::send - cannot send header, header has already been send.");
     }
     if ($headers) {
         // status header
         header(CCIn::server('SERVER_PROTOCOL') . ' ' . $this->_status . ' ' . CCResponse::$messages[$this->_status]);
         // check if content type is already set
         if (!isset($this->_header['Content-Type'])) {
             $this->header('Content-Type', 'text/html; charset=' . ClanCats::$config->get('charset', 'utf-8'));
         }
         $this->header('X-Powered-By', 'ClanCatsFramework version: ' . ClanCats::VERSION);
         // set headers
         foreach ($this->_header as $key => $content) {
             header($key . ': ' . $content);
         }
     }
     // profiler
     CCProfiler::check('CCResponse - sending response');
     // print the body
     echo CCEvent::pass('response.output', $this->body());
 }