protected function generateResponseForRequest($request = false)
 {
     if ($this->staticFile !== false) {
         $response = new Response();
         LayoutModule::disableLayout();
         if (substr($this->staticFile, -4) == ".css") {
             $mime = "text/css";
         } else {
             $info = new \finfo(FILEINFO_MIME);
             $mime = $info->file($this->staticFile);
         }
         if ($mime !== false) {
             if (substr($this->staticFile, -3) == ".js") {
                 $mime = str_replace("text/plain", "application/javascript", $mime);
             }
             HttpHeaders::setHeader("Content-type", $mime);
             $response->setHeader('Content-Type', $mime);
         }
         ob_start();
         readfile($this->staticFile);
         $response->setContent(ob_get_clean());
         return $response;
     }
     return false;
 }
예제 #2
0
 public function testHeadersAreFlushed()
 {
     HttpHeaders::clearHeaders();
     HttpHeaders::setHeader("Content-type", "text/plain");
     HttpHeaders::flushHeaders();
     $headers = HttpHeaders::getHeaders();
     $this->assertTrue(HttpHeaders::$flushed);
 }
 public function testHandlerRedirectsToIndexPage()
 {
     HttpHeaders::clearHeaders();
     // This folder does contain an index so it should redirect.
     $this->request->UrlPath = "/nmh/SubFolder/";
     $response = Module::generateResponseForRequest($this->request);
     $headers = $response->getHeaders();
     $this->assertEquals("/nmh/SubFolder/index/", $headers["Location"]);
 }
예제 #4
0
 private function processHeaders()
 {
     foreach ($this->headers as $name => $value) {
         HttpHeaders::setHeader($name, $value);
     }
     HttpHeaders::flushHeaders();
 }
예제 #5
0
 public function generateResponseForRequest($request = null)
 {
     HttpHeaders::setContentType('application/download');
     return parent::generateResponseForRequest($request);
 }