diff --git a/src/HttpServer.php b/src/HttpServer.php index 3b95e15..234eb2d 100644 --- a/src/HttpServer.php +++ b/src/HttpServer.php @@ -53,11 +53,13 @@ public function onRequest($request, $response): void $path = $psr7Request->getUri()->getPath(); if ($path === $this->config['url']) { $stream = new Stream($this->getHtml()); + $contentType = 'text/html;charset=utf-8'; } else { $stream = new Stream($this->getMetadata($path)); + $contentType = 'application/json;charset=utf-8'; } - $psrResponse = (new Response())->withBody($stream); + $psrResponse = (new Response())->setBody($stream)->setHeader('content-type', $contentType); $this->emitter->emit($psrResponse, $response); }