Example #1
0
 public function testInvalidContentType()
 {
     $this->assertEquals('application/octet-stream', ContentType::getType('foo'));
 }
Example #2
0
 /**
  * @param Request               $request
  * @param ProtectedStreamSocket $socket
  *
  * @throws ResourceNotFoundException
  *
  * @return Response
  */
 protected function handleRequest(Request $request, ProtectedStreamSocket $socket)
 {
     try {
         $file = $this->findFile($request);
         if ($processor = $this->findProcessor($file)) {
             $response = $processor->execute($file, $request, $this->env);
         } else {
             $response = new Response(file_get_contents($file));
             $response->setHeader('Content-Type', ContentType::getType($file->getExtension()));
         }
     } catch (ResourceNotFoundException $e) {
         $response = $this->handleError(404, $e);
     } catch (Exception $e) {
         $response = $this->handleError(500, $e);
     }
     $this->logger->log($response->getCode(), (string) $request);
     if ($error = $response->getError()) {
         $this->logger->log(-1, $error);
     }
     return $response;
 }