jdecool/scaleway-runtimepublic Fork
⑂ 9fccae2
Commits
⬇ Clone ▾
git clone https://git.rickub.com/jdecool/scaleway-runtime.git
git clone ssh://git@rickub.com/jdecool/scaleway-runtime.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

fix: give Events without Host the localhost default of Request::create()Unverified

A Kernel saw "http://:/" as the URI of such an Event, which CRON Invocations
may well be; the PSR-15 runner had its own fallback, now redundant.
Jérémy DECOOL committed 2026-11-13T22:57:06+01:00 Browse files
9fccae2 parent: 9ef9df2
modified src/HttpConverter.php +3 -0
@@ -69,6 +69,9 @@ final class HttpConverter
6969 $contentType = strtolower($value);
7070 }
7171 }
72+ // Events need not carry a Host (CRON ones may not), and without it the Request's URI would be "http://:/";
73+ // Request::create() falls back to the same default.
74+ $server['HTTP_HOST'] ??= 'localhost';
7275
7376 // PHP only parses form bodies into $_POST for POST; Symfony's createFromGlobals() covers the other body methods.
7477 $post = $files = [];
@@ -69,6 +69,9 @@ final class HttpConverter
69 $contentType = strtolower($value);69 $contentType = strtolower($value);
70 }70 }
71 }71 }
72+ // Events need not carry a Host (CRON ones may not), and without it the Request's URI would be "http://:/";
73+ // Request::create() falls back to the same default.
74+ $server['HTTP_HOST'] ??= 'localhost';
72 75
73 // PHP only parses form bodies into $_POST for POST; Symfony's createFromGlobals() covers the other body methods.76 // PHP only parses form bodies into $_POST for POST; Symfony's createFromGlobals() covers the other body methods.
74 $post = $files = [];77 $post = $files = [];
modified src/Runner/RequestHandlerKernel.php +2 -3
@@ -49,9 +49,8 @@ final class RequestHandlerKernel implements HttpKernelInterface
4949 try {
5050 $server = [
5151 'REMOTE_ADDR' => $request->getClientIp(),
52- // PSR-7 needs a parsable URI; an Event without Host gets the default of Request::create().
53- 'HTTP_HOST' => '' === $request->getHost() ? 'localhost' : $request->getHttpHost(),
54- 'SERVER_PORT' => $request->getPort() ?? ($request->isSecure() ? 443 : 80),
52+ 'HTTP_HOST' => $request->getHttpHost(),
53+ 'SERVER_PORT' => $request->getPort(),
5554 'HTTPS' => $request->isSecure() ? 'on' : 'off',
5655 ] + $request->server->all();
5756 } catch (SuspiciousOperationException) {
@@ -49,9 +49,8 @@ final class RequestHandlerKernel implements HttpKernelInterface
49 try {49 try {
50 $server = [50 $server = [
51 'REMOTE_ADDR' => $request->getClientIp(),51 'REMOTE_ADDR' => $request->getClientIp(),
52- // PSR-7 needs a parsable URI; an Event without Host gets the default of Request::create().52+ 'HTTP_HOST' => $request->getHttpHost(),
53- 'HTTP_HOST' => '' === $request->getHost() ? 'localhost' : $request->getHttpHost(),53+ 'SERVER_PORT' => $request->getPort(),
54- 'SERVER_PORT' => $request->getPort() ?? ($request->isSecure() ? 443 : 80),
55 'HTTPS' => $request->isSecure() ? 'on' : 'off',54 'HTTPS' => $request->isSecure() ? 'on' : 'off',
56 ] + $request->server->all();55 ] + $request->server->all();
57 } catch (SuspiciousOperationException) {56 } catch (SuspiciousOperationException) {
modified tests/HttpConverterTest.php +8 -0
@@ -267,6 +267,14 @@ final class HttpConverterTest extends TestCase
267267 self::assertSame('internal.local', $request->getHost());
268268 }
269269
270+ public function testEventWithoutHostGetsTheDefaultHostOfRequestCreate(): void
271+ {
272+ $request = HttpConverter::toRequest(['path' => '/jobs', 'method' => 'POST']);
273+
274+ self::assertSame('http://localhost/jobs', $request->getUri());
275+ self::assertSame(80, $request->getPort());
276+ }
277+
270278 public function testFunctionResponseFromTextResponse(): void
271279 {
272280 $response = new Response('{"a":"é"}', 201, ['Content-Type' => 'application/json']);
@@ -267,6 +267,14 @@ final class HttpConverterTest extends TestCase
267 self::assertSame('internal.local', $request->getHost());267 self::assertSame('internal.local', $request->getHost());
268 }268 }
269 269
270+ public function testEventWithoutHostGetsTheDefaultHostOfRequestCreate(): void
271+ {
272+ $request = HttpConverter::toRequest(['path' => '/jobs', 'method' => 'POST']);
273+
274+ self::assertSame('http://localhost/jobs', $request->getUri());
275+ self::assertSame(80, $request->getPort());
276+ }
277+
270 public function testFunctionResponseFromTextResponse(): void278 public function testFunctionResponseFromTextResponse(): void
271 {279 {
272 $response = new Response('{"a":"é"}', 201, ['Content-Type' => 'application/json']);280 $response = new Response('{"a":"é"}', 201, ['Content-Type' => 'application/json']);