getContentType() public method

Get the MIME type.
public getContentType ( ) : string
return string
コード例 #1
0
 public function testResponse()
 {
     $serverResponse = new ServerResponse('Hola user!');
     $this->assertEquals('Hola user!', $serverResponse->getContent());
     $this->assertEquals(200, $serverResponse->getStatusCode());
     $this->assertEquals('text/html', $serverResponse->getContentType());
     $serverResponse->setContent('Hola user again!');
     $this->assertEquals('Hola user again!', $serverResponse->getContent());
     $serverResponse->setStatusCode(204);
     $this->assertEquals(204, $serverResponse->getStatusCode());
     $serverResponse->setContentType('text/xml');
     $this->assertEquals('text/xml', $serverResponse->getContentType());
 }
コード例 #2
0
ファイル: HttpServer.php プロジェクト: jjk-jacky/Spress
 private function buildFinalResponse(ServerResponse $response)
 {
     $finalResponse = ['content' => $response->getContent(), 'headers' => ['Content-Type' => $response->getContentType()], 'status_code' => $response->getStatusCode()];
     if ($finalResponse['status_code'] >= 400) {
         $model = $this->getErrorModel($finalResponse['status_code'], $finalResponse['content']);
         $finalResponse['content'] = $this->twig->render($this->errorDocument, $model);
     }
     return $finalResponse;
 }