From b5fc6c80512b7a23fec5f871f62e94ffd8769a78 Mon Sep 17 00:00:00 2001
From: Ivan Zorin
Date: Fri, 20 Nov 2026 09:34:11 +0300
Subject: [PATCH] feat!: migrate Engine HTTP to Server 7
---
.github/workflows/php.yml | 13 +-
CHANGELOG.md | 16 ++
README.md | 58 +++++++
README.ru.md | 57 +++++++
composer.json | 5 +-
rector.php | 2 +-
src/App.php | 16 +-
src/Config/app.php | 8 +-
src/Config/exception.php | 4 +-
src/Config/static.php | 2 +-
src/Install.php | 2 +-
src/Support/Request.php | 2 +-
tests/Server7HttpLoopbackTest.php | 177 +++++++++++++++++++++
tests/Server7ResponseCompatibilityTest.php | 56 +++++++
tests/fixtures/server7_http.php | 66 ++++++++
tools/test-server7-local.sh | 30 ++++
16 files changed, 492 insertions(+), 22 deletions(-)
create mode 100644 README.ru.md
create mode 100644 tests/Server7HttpLoopbackTest.php
create mode 100644 tests/Server7ResponseCompatibilityTest.php
create mode 100644 tests/fixtures/server7_http.php
create mode 100644 tools/test-server7-local.sh
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index d521c32..685b5b6 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['8.1', '8.5']
+ php: ['8.1', '8.2', '8.3', '8.4', '8.5']
steps:
- name: Checkout
uses: actions/checkout@v7
@@ -31,11 +31,11 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
coverage: none
- - name: Validate Composer manifest and lock
- run: composer validate --no-check-publish --no-interaction
+ - name: Validate Composer manifest
+ run: composer validate --no-check-publish --no-check-lock --no-interaction
- - name: Install locked dependencies
- run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
+ - name: Resolve and install dependencies
+ run: composer update --prefer-dist --no-interaction --no-progress --no-scripts
- name: Check PHP syntax
run: find . -path './vendor' -prune -o -path './.git' -prune -o -name '*.php' -type f -print0 | xargs -0 -n1 php -l
@@ -48,3 +48,6 @@ jobs:
else
echo 'No test script is declared for this package.'
fi
+
+ - name: Audit dependencies
+ run: composer audit --abandoned=report
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b929117..8a0e914 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [3.0.0] - 2026-11-20
+
+### Changed
+- Require Triangle Engine 9, Router 2, and Middleware 2 for Localzet Server 7.
+- Preserve status, headers, and body when a handler returns a Localzet Server HTTP response.
+- Read default response headers from the Engine 9 `app.http_headers` setting.
+- Remove permissive wildcard CORS defaults; applications must configure allowed origins explicitly.
+
+### Added
+- Add regression coverage for response conversion, default headers, and a loopback HTTP request on Server 7.
+- Add bilingual installation, migration, and security instructions.
+- Expand CI coverage to PHP 8.1–8.5 and audit dependencies.
+
+### Compatibility
+- This is a major release. The 2.x line remains for applications using the previous Engine compatibility line.
+
## [1.0.0] - 2025-01-XX - LTS Release
### Added
diff --git a/README.md b/README.md
index 7fc4219..82524bc 100644
--- a/README.md
+++ b/README.md
@@ -19,3 +19,61 @@
+
+# Triangle Engine HTTP
+
+HTTP adapter for Triangle applications. It connects request handling to Localzet Server 7, Triangle Router, and Middleware; the application bootstrap remains responsible for configuration, routes, and listener startup.
+
+## Compatibility
+
+Release 3.x targets PHP 8.1+, Localzet Server 7.1+, Triangle Engine 9, Router 2, Middleware 2, and the PHP cURL extension. Release 2.x remains on the earlier Engine compatibility line. Do not mix the two dependency sets in one lock file.
+
+## Install
+
+```bash
+composer require triangle/engine-http:^3.0
+```
+
+Follow the [installation guide](https://server.localzet.com/projects/engine-http/install) for the complete bootstrap and version checks.
+
+## Request and response flow
+
+Register routes before collecting the Router dispatcher:
+
+```php
+use localzet\Server\Protocols\Http\Response;
+use Triangle\Router;
+
+Router::any('/health', static fn () => new Response(
+ 200,
+ ['Content-Type' => 'application/json'],
+ '{"status":"ok"}',
+));
+
+Router::collect([]);
+```
+
+Engine HTTP sends requests through route middleware and controller resolution. A Localzet Server HTTP response keeps its status, headers, and body. Other return values become a `200` response with a string body.
+
+## Security and limits
+
+- Authentication and authorization belong to the application or its middleware.
+- CORS is not enabled by default. Configure `app.http_headers` with explicit origins and headers when cross-origin access is required.
+- PHP files under a public path are disabled by default; enable them only when the application has a clear need and a reviewable execution boundary.
+- Listener, HTTP framing, worker lifecycle, and backpressure are provided by Localzet Server.
+
+See the [request guide](https://server.localzet.com/projects/engine-http/requests), [configuration](https://server.localzet.com/projects/engine-http/architecture), and [security guide](https://server.localzet.com/projects/engine-http/security) for production setup.
+
+## Checks
+
+```bash
+composer validate --strict --no-check-publish --no-interaction
+composer run test --no-interaction
+composer audit --abandoned=report
+```
+
+The test command covers response compatibility and a loopback HTTP request against Server 7.
+
+## License
+
+AGPL-3.0-or-later. See [LICENSE](LICENSE).
diff --git a/README.ru.md b/README.ru.md
new file mode 100644
index 0000000..06a05fe
--- /dev/null
+++ b/README.ru.md
@@ -0,0 +1,57 @@
+# Triangle Engine HTTP
+
+HTTP-адаптер для приложений Triangle. Он связывает обработку запросов с Localzet Server 7, Router и Middleware Triangle. Конфигурация приложения, маршруты и запуск listener-а остаются ответственностью bootstrap проекта.
+
+## Совместимость
+
+Версия 3.x рассчитана на PHP 8.1+, Localzet Server 7.1+, Triangle Engine 9, Router 2, Middleware 2 и расширение PHP cURL. Версия 2.x относится к прежней ветке совместимости Engine. Не смешивайте эти наборы зависимостей в одном lock-файле.
+
+## Установка
+
+```bash
+composer require triangle/engine-http:^3.0
+```
+
+Полный порядок запуска и проверки версий описан в [руководстве по установке](https://server.localzet.com/projects/engine-http/install).
+
+## Обработка запроса и ответа
+
+Регистрируйте маршруты до сборки dispatcher-а Router:
+
+```php
+use localzet\Server\Protocols\Http\Response;
+use Triangle\Router;
+
+Router::any('/health', static fn () => new Response(
+ 200,
+ ['Content-Type' => 'application/json'],
+ '{"status":"ok"}',
+));
+
+Router::collect([]);
+```
+
+Engine HTTP передаёт запрос через middleware маршрута и разрешение контроллеров. HTTP-ответ Localzet Server сохраняет статус, заголовки и тело. Остальные значения превращаются в ответ `200` со строковым телом.
+
+## Безопасность и ограничения
+
+- Аутентификацию и проверку прав настраивает приложение или его middleware.
+- CORS по умолчанию выключен. Если нужен доступ с другого origin, задайте явные origin и заголовки в `app.http_headers`.
+- Выполнение PHP-файлов внутри публичного каталога по умолчанию выключено. Включайте его только при ясной необходимости и проверяемой границе исполнения.
+- Listener, HTTP framing, жизненный цикл worker-ов и backpressure реализует Localzet Server.
+
+Смотрите [обработку запросов](https://server.localzet.com/projects/engine-http/requests), [конфигурацию](https://server.localzet.com/projects/engine-http/architecture) и [руководство по безопасности](https://server.localzet.com/projects/engine-http/security).
+
+## Проверки
+
+```bash
+composer validate --strict --no-check-publish --no-interaction
+composer run test --no-interaction
+composer audit --abandoned=report
+```
+
+Тесты проверяют совместимость ответов и HTTP-запрос к Server 7 через loopback.
+
+## Лицензия
+
+AGPL-3.0-or-later. Текст лицензии — в файле [LICENSE](LICENSE).
diff --git a/composer.json b/composer.json
index d60970f..7feb7a1 100644
--- a/composer.json
+++ b/composer.json
@@ -29,7 +29,7 @@
"require": {
"php": "^8.1",
"ext-curl": "*",
- "triangle/engine": "^8",
+ "triangle/engine": "^9.0",
"triangle/router": "^2",
"triangle/middleware": "^2"
},
@@ -43,6 +43,9 @@
"require-dev": {
"rector/rector": "*"
},
+ "scripts": {
+ "test": "php tests/Server7ResponseCompatibilityTest.php && php tests/Server7HttpLoopbackTest.php"
+ },
"conflict": {
"triangle/engine-ws": "*"
},
diff --git a/rector.php b/rector.php
index 58d0542..6284b2b 100644
--- a/rector.php
+++ b/rector.php
@@ -5,7 +5,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/App.php b/src/App.php
index 7ec9f1c..49ce163 100644
--- a/src/App.php
+++ b/src/App.php
@@ -5,7 +5,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
@@ -29,6 +29,7 @@
use Closure;
use localzet\Server\Connection\ConnectionInterface;
use localzet\Server\Connection\TcpConnection;
+use localzet\Server\Protocols\Http\Response as ServerResponse;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionException;
@@ -186,14 +187,14 @@ public static function getCallback(?string $plugin, string $app, $call, array $a
$call = static::resolveInject($plugin, $call, $args);
}
- $callback = function ($request) use ($call, $anonymousArgs): \Triangle\Engine\Response {
+ $callback = function ($request) use ($call, $anonymousArgs): ServerResponse {
try {
$response = $anonymousArgs ? $call($request, ...$anonymousArgs) : $call($request);
} catch (Throwable $throwable) {
return static::exceptionResponse($throwable, $request);
}
- return $response instanceof Response ? $response : new Response(200, [], static::stringify($response));
+ return static::normalizeResponse($response);
};
return $middlewares ? array_reduce($middlewares, fn($carry, $pipe): \Closure => function ($request) use ($carry, $pipe) {
@@ -217,7 +218,7 @@ protected static function send(mixed $connection, mixed $response, mixed $reques
if (($keepAlive === null
&& $request->protocolVersion() === '1.1')
|| $keepAlive === 'keep-alive' || $keepAlive === 'Keep-Alive'
- || ($response instanceof Response
+ || ($response instanceof ServerResponse
&& $response->getHeader('Transfer-Encoding') === 'chunked')
) {
$connection->send($response);
@@ -227,6 +228,13 @@ protected static function send(mixed $connection, mixed $response, mixed $reques
$connection->close($response);
}
+ protected static function normalizeResponse(mixed $response): ServerResponse
+ {
+ return $response instanceof ServerResponse
+ ? $response
+ : new Response(200, [], static::stringify($response));
+ }
+
protected static function getFallback(?string $plugin = '', int $status = 404): Closure
{
diff --git a/src/Config/app.php b/src/Config/app.php
index 9290b1e..7a91e7f 100644
--- a/src/Config/app.php
+++ b/src/Config/app.php
@@ -5,7 +5,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
@@ -36,12 +36,8 @@
'controller_suffix' => env('CONTROLLER_SUFFIX', ''),
'controller_reuse' => env('CONTROLLER_REUSE', true),
- 'headers' => [
+ 'http_headers' => [
'Content-Language' => 'ru',
- 'Access-Control-Allow-Origin' => '*',
- 'Access-Control-Allow-Credentials' => 'true',
- 'Access-Control-Allow-Methods' => '*',
- 'Access-Control-Allow-Headers' => '*',
'X-Powered-By' => 'Triangle-Core/' . Composer\InstalledVersions::getVersion('triangle/engine'),
],
];
diff --git a/src/Config/exception.php b/src/Config/exception.php
index 4d5c432..541cb29 100644
--- a/src/Config/exception.php
+++ b/src/Config/exception.php
@@ -5,7 +5,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2024 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Config/static.php b/src/Config/static.php
index 3fe4806..9635bc0 100644
--- a/src/Config/static.php
+++ b/src/Config/static.php
@@ -5,7 +5,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Install.php b/src/Install.php
index 64438b7..28b3109 100644
--- a/src/Install.php
+++ b/src/Install.php
@@ -5,7 +5,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Support/Request.php b/src/Support/Request.php
index 136da7d..03b217a 100644
--- a/src/Support/Request.php
+++ b/src/Support/Request.php
@@ -5,7 +5,7 @@
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/tests/Server7HttpLoopbackTest.php b/tests/Server7HttpLoopbackTest.php
new file mode 100644
index 0000000..f7e007c
--- /dev/null
+++ b/tests/Server7HttpLoopbackTest.php
@@ -0,0 +1,177 @@
+.
+ */
+
+if (PHP_OS_FAMILY === 'Windows' || !function_exists('proc_open') || !function_exists('posix_kill')) {
+ fwrite(STDOUT, "Server 7 HTTP loopback test skipped: Unix process support is required.\n");
+ exit(0);
+}
+
+$runtimeDirectory = sys_get_temp_dir() . '/triangle-engine-http-adapter-' . bin2hex(random_bytes(8));
+if (!mkdir($runtimeDirectory, 0700)) {
+ throw new RuntimeException('Could not create the HTTP loopback runtime directory.');
+}
+
+$process = null;
+
+try {
+ $port = reservePort();
+ $logFile = $runtimeDirectory . '/server.log';
+ $process = proc_open(
+ [PHP_BINARY, __DIR__ . '/fixtures/server7_http.php', 'start', (string)$port, $runtimeDirectory],
+ [
+ 0 => ['pipe', 'r'],
+ 1 => ['file', $logFile, 'a'],
+ 2 => ['file', $logFile, 'a'],
+ ],
+ $pipes,
+ dirname(__DIR__),
+ );
+
+ if (!is_resource($process)) {
+ throw new RuntimeException('Could not start the Server 7 HTTP fixture.');
+ }
+
+ if (isset($pipes[0]) && is_resource($pipes[0])) {
+ fclose($pipes[0]);
+ }
+
+ waitForServer($port, $process, $logFile);
+
+ $socket = stream_socket_client("tcp://127.0.0.1:$port", $errorCode, $errorMessage, 2);
+ if (!is_resource($socket)) {
+ throw new RuntimeException("Could not connect to the Server 7 HTTP fixture: $errorMessage ($errorCode)");
+ }
+
+ stream_set_timeout($socket, 3);
+ fwrite($socket, "GET /server-response HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n");
+ $response = stream_get_contents($socket);
+ fclose($socket);
+
+ if (!is_string($response) || !str_starts_with($response, 'HTTP/1.1 202')) {
+ throw new RuntimeException('The adapter did not preserve the base HTTP response status. Received: ' . (string)$response);
+ }
+
+ [$headers, $body] = array_pad(explode("\r\n\r\n", $response, 2), 2, '');
+ if (stripos($headers, "\r\nX-Adapter-Test: preserved") === false) {
+ throw new RuntimeException('The adapter did not preserve the base HTTP response header.');
+ }
+
+ if ($body !== 'response from a base Server 7 HTTP response') {
+ throw new RuntimeException('The adapter changed the base HTTP response body: ' . $body);
+ }
+} finally {
+ if (is_resource($process)) {
+ stopServer($process, $runtimeDirectory);
+ }
+
+ foreach (glob($runtimeDirectory . '/*') ?: [] as $file) {
+ if (is_dir($file)) {
+ foreach (glob($file . '/*') ?: [] as $child) {
+ @unlink($child);
+ }
+ @rmdir($file);
+ } else {
+ @unlink($file);
+ }
+ }
+ @rmdir($runtimeDirectory);
+}
+
+fwrite(STDOUT, "Server 7 HTTP loopback compatibility passed.\n");
+
+function reservePort(): int
+{
+ $socket = stream_socket_server('tcp://127.0.0.1:0', $errorCode, $errorMessage);
+ if (!is_resource($socket)) {
+ throw new RuntimeException("Could not reserve a loopback port: $errorMessage ($errorCode)");
+ }
+
+ $address = stream_socket_get_name($socket, false);
+ fclose($socket);
+
+ return (int)substr(strrchr((string)$address, ':'), 1);
+}
+
+function waitForServer(int $port, $process, string $logFile): void
+{
+ $deadline = microtime(true) + 5;
+ do {
+ $socket = @stream_socket_client("tcp://127.0.0.1:$port", $errorCode, $errorMessage, 0.05);
+ if (is_resource($socket)) {
+ fclose($socket);
+ return;
+ }
+
+ if (!proc_get_status($process)['running']) {
+ throw new RuntimeException('Server 7 exited during startup: ' . readLog($logFile));
+ }
+
+ usleep(50_000);
+ } while (microtime(true) < $deadline);
+
+ throw new RuntimeException('Server 7 did not start the HTTP listener: ' . readLog($logFile));
+}
+
+function stopServer($process, string $runtimeDirectory): void
+{
+ $status = proc_get_status($process);
+ $masterPid = (int)$status['pid'];
+
+ if ($status['running']) {
+ proc_terminate($process, SIGTERM);
+ $deadline = microtime(true) + 5;
+ do {
+ usleep(50_000);
+ $status = proc_get_status($process);
+ } while ($status['running'] && microtime(true) < $deadline);
+ }
+
+ $processGroup = (int)@file_get_contents($runtimeDirectory . '/process-group');
+ if ($processGroup === $masterPid && ($status['running'] || hasRunningWorker($runtimeDirectory, $masterPid))) {
+ @posix_kill(-$processGroup, SIGKILL);
+ } elseif ($status['running']) {
+ proc_terminate($process, SIGKILL);
+ }
+
+ proc_close($process);
+}
+
+function hasRunningWorker(string $runtimeDirectory, int $masterPid): bool
+{
+ foreach (glob($runtimeDirectory . '/server.status.d/worker-*.json') ?: [] as $file) {
+ $worker = json_decode((string)file_get_contents($file), true);
+ $workerPid = (int)($worker['pid'] ?? 0);
+
+ if (($worker['master_pid'] ?? null) === $masterPid
+ && $workerPid > 1
+ && @posix_kill($workerPid, 0)
+ && @posix_getpgid($workerPid) === $masterPid) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function readLog(string $logFile): string
+{
+ return is_file($logFile) ? (string)file_get_contents($logFile) : '';
+}
diff --git a/tests/Server7ResponseCompatibilityTest.php b/tests/Server7ResponseCompatibilityTest.php
new file mode 100644
index 0000000..7417ab5
--- /dev/null
+++ b/tests/Server7ResponseCompatibilityTest.php
@@ -0,0 +1,56 @@
+.
+ */
+
+require getenv('ENGINE_HTTP_VENDOR_AUTOLOAD') ?: dirname(__DIR__) . '/vendor/autoload.php';
+
+use localzet\Server\Protocols\Http\Response as ServerResponse;
+use Triangle\Engine\Config;
+use Triangle\Engine\Response as EngineResponse;
+use Triangle\Http\App;
+
+$normalizeResponse = new ReflectionMethod(App::class, 'normalizeResponse');
+$serverResponse = new ServerResponse(201, ['X-Test' => 'preserved'], 'response body');
+$normalizedResponse = $normalizeResponse->invoke(null, $serverResponse);
+
+if ($normalizedResponse !== $serverResponse) {
+ throw new RuntimeException('A Server HTTP response must pass through unchanged.');
+}
+
+if (!$normalizedResponse instanceof ServerResponse) {
+ throw new RuntimeException('The callback result must remain an HTTP response object.');
+}
+
+$normalizedValue = $normalizeResponse->invoke(null, 'plain body');
+if (!$normalizedValue instanceof EngineResponse) {
+ throw new RuntimeException('A plain callback value must be wrapped in an Engine response.');
+}
+
+Config::set(['app' => require dirname(__DIR__) . '/src/Config/app.php']);
+$configuredResponse = new EngineResponse();
+if ($configuredResponse->getHeader('Content-Language') !== 'ru') {
+ throw new RuntimeException('Engine response defaults must use the Engine 9 http_headers setting.');
+}
+
+if ($configuredResponse->getHeader('Access-Control-Allow-Origin') !== null) {
+ throw new RuntimeException('CORS origins must be explicitly configured by the application.');
+}
+
+fwrite(STDOUT, "Server HTTP response compatibility passed.\n");
diff --git a/tests/fixtures/server7_http.php b/tests/fixtures/server7_http.php
new file mode 100644
index 0000000..1e28f10
--- /dev/null
+++ b/tests/fixtures/server7_http.php
@@ -0,0 +1,66 @@
+.
+ */
+
+use localzet\Server;
+use localzet\Server\Protocols\Http;
+use localzet\Server\Protocols\Http\Response as ServerResponse;
+use Monolog\Logger;
+use Triangle\Engine\Context;
+use Triangle\Engine\Request;
+use Triangle\Http\App;
+
+$port = (int)($argv[2] ?? 0);
+$runtimeDirectory = (string)($argv[3] ?? '');
+
+if (!function_exists('posix_setpgid') || !posix_setpgid(0, 0) || posix_getpgrp() !== getmypid()) {
+ fwrite(STDERR, "Could not isolate the HTTP integration process group.\n");
+ exit(1);
+}
+
+file_put_contents($runtimeDirectory . '/process-group', (string)posix_getpgrp(), LOCK_EX);
+
+$autoload = getenv('ENGINE_HTTP_VENDOR_AUTOLOAD') ?: dirname(__DIR__, 2) . '/vendor/autoload.php';
+require $autoload;
+
+Server::$pidFile = $runtimeDirectory . '/server.pid';
+Server::$statusFile = $runtimeDirectory . '/server.status';
+Server::$stdoutFile = $runtimeDirectory . '/stdout.log';
+Server::$logFile = $runtimeDirectory . '/server.log';
+
+Http::requestClass(Request::class);
+Context::init();
+
+$app = new App(Request::class, new Logger('engine-http-loopback'));
+$callback = App::getCallback(null, '', static fn($request) => new ServerResponse(
+ 202,
+ ['X-Adapter-Test' => 'preserved', 'Connection' => 'close'],
+ 'response from a base Server 7 HTTP response',
+));
+
+$collectCallback = new ReflectionMethod(App::class, 'collectCallbacks');
+$collectCallback->setAccessible(true);
+$collectCallback->invoke(null, 'GET/server-response', [$callback, '', '', '', '', null]);
+
+$server = new Server("http://127.0.0.1:$port");
+$server->count = 1;
+$server->onMessage = [$app, 'onMessage'];
+
+Server::runAll();
diff --git a/tools/test-server7-local.sh b/tools/test-server7-local.sh
new file mode 100644
index 0000000..927d7bc
--- /dev/null
+++ b/tools/test-server7-local.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+manifest="$(mktemp "$repo_dir/.composer-server7.XXXXXX.json")"
+vendor_dir="$(mktemp -d "${TMPDIR:-/tmp}/engine-http-server7-vendor.XXXXXX")"
+lock_file="${manifest%.json}.lock"
+
+cleanup() {
+ rm -f "$manifest" "$lock_file"
+ rm -rf "$vendor_dir"
+}
+trap cleanup EXIT
+
+cp "$repo_dir/composer.json" "$manifest"
+COMPOSER="$manifest" composer config minimum-stability dev
+COMPOSER="$manifest" composer config prefer-stable true
+
+COMPOSER="$manifest" composer config repositories.server7-engine \
+ '{"type":"path","url":"../Engine","options":{"symlink":true,"versions":{"triangle/engine":"9.0.x-dev"}}}'
+COMPOSER="$manifest" composer config repositories.server7-router \
+ '{"type":"path","url":"../Component-Router","options":{"symlink":true,"versions":{"triangle/router":"2.0.x-dev"}}}'
+COMPOSER="$manifest" composer config repositories.server7-middleware \
+ '{"type":"path","url":"../Component-Middleware","options":{"symlink":true,"versions":{"triangle/middleware":"2.0.x-dev"}}}'
+
+COMPOSER="$manifest" COMPOSER_VENDOR_DIR="$vendor_dir" composer update \
+ --with-all-dependencies --prefer-dist --no-interaction --no-progress --no-scripts
+
+COMPOSER="$manifest" COMPOSER_VENDOR_DIR="$vendor_dir" \
+ENGINE_HTTP_VENDOR_AUTOLOAD="$vendor_dir/autoload.php" composer test --no-interaction