diff --git a/CHANGELOG.md b/CHANGELOG.md index d484f2f..b51f180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Changed + +- Requires `innmind/operating-system:~6.0` +- Requires `innmind/http:~8.0` + ### Fixed - PHP `8.4` deprecation diff --git a/composer.json b/composer.json index a7e20a0..1dc9431 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ }, "require": { "php": "~8.2", - "innmind/http": "~7.0", - "innmind/operating-system": "~4.0|~5.0" + "innmind/http": "~8.0", + "innmind/operating-system": "~6.0" }, "autoload": { "psr-4": { diff --git a/fixtures/index.php b/fixtures/index.php index 0ce05a0..6e6e9fd 100644 --- a/fixtures/index.php +++ b/fixtures/index.php @@ -4,22 +4,23 @@ require __DIR__.'/../vendor/autoload.php'; use Innmind\HttpServer\Main; -use Innmind\Http\Message\{ +use Innmind\Http\{ ServerRequest, Response, - StatusCode, + Response\StatusCode, }; +use Innmind\Filesystem\File\Content; new class extends Main { protected function main(ServerRequest $request): Response { - //echo back server - return new Response\Response( + // Echo back server + return Response::of( StatusCode::ok, $request->protocolVersion(), null, - $request->body(), + Content::ofString('Hello world'), ); } }; diff --git a/src/Main.php b/src/Main.php index f9c9d08..c86ca0a 100644 --- a/src/Main.php +++ b/src/Main.php @@ -4,8 +4,8 @@ namespace Innmind\HttpServer; use Innmind\Http\{ - Factory\ServerRequest\ServerRequestFactory, - ResponseSender, + Factory\ServerRequestFactory, + Response\Sender\Native, ServerRequest, ServerRequest\Environment, Response, @@ -25,8 +25,8 @@ abstract class Main final public function __construct(?Config $config = null) { $os = Factory::build($config); - $makeRequest = ServerRequestFactory::default($os->clock()); - $send = new ResponseSender($os->clock()); + $makeRequest = ServerRequestFactory::native($os->clock()); + $send = Native::of($os->clock()); try { $request = $makeRequest(); @@ -41,10 +41,12 @@ final public function __construct(?Config $config = null) try { $response = $this->main($request); } catch (\Throwable $e) { + throw $e; $response = $this->serverError($request); } - $send($response); + // Swallow errors to never render them to the client + $_ = $send($response)->memoize(); $this->terminate($request, $response); }