protected function serveResource(WebAppRequest $request, WebAppResponse $response, $content) { //$webAppPath = $request->getUrlPath(); // identify the requested resource path $path = $this->getRelativePath($request); $resource = substr(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome(), 0, -1) . $path; // make sure that this path exists on disk if (!file_exists($resource)) { $response->sendError(WebAppResponse::SC_NOT_FOUND, $request->getRequestURI()); return; } // if this is a directory, first check welcome files...if that fails // see if we can do a listing if (is_dir($resource)) { $welcomeFile = $this->findWelcomeFile($path); if ($welcomeFile != null) { $response->sendRedirect($this->getURL($request, $welcomeFile)); $response->flushBuffer(); return; } if ($this->listings == 'false') { $response->sendError(WebAppResponse::SC_FORBIDDEN, $request->getRequestURI()); return; } else { if ($content) { // serve up the directory listing $response->setContentType('text/html'); echo $this->renderListing($request, $webAppPath, $path, $resource); return; } } } if ($content) { // we are serving up an actual file here, which we know exists $contentType = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getMimeType($resource); if (!is_null($contentType)) { $response->setContentType($contentType); } $response->addDateHeader('Last-Modified', filemtime($resource)); readfile($resource); } }