jdecool/scaleway-runtimepublic Fork
⑂ ee88812
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 with an empty Host the localhost default tooUnverified

An empty Host header left the Request URI at "http://:/", and PSR-15
Applications, which no longer default the host themselves, failed with a
500 on such Events.
Jérémy DECOOL committed 2026-11-14T02:07:02+01:00 Browse files
ee88812 parent: 5b47e80
modified src/HttpConverter.php +4 -2
@@ -69,9 +69,11 @@ 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://:/";
72+ // Events need not carry a Host (CRON ones may not), and without one the Request's URI would be "http://:/";
7373 // Request::create() falls back to the same default.
74- $server['HTTP_HOST'] ??= 'localhost';
74+ if ('' === ($server['HTTP_HOST'] ?? '')) {
75+ $server['HTTP_HOST'] = 'localhost';
76+ }
7577
7678 // PHP only parses form bodies into $_POST for POST; Symfony's createFromGlobals() covers the other body methods.
7779 $post = $files = [];
@@ -69,9 +69,11 @@ 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://:/";72+ // Events need not carry a Host (CRON ones may not), and without one the Request's URI would be "http://:/";
73 // Request::create() falls back to the same default.73 // Request::create() falls back to the same default.
74- $server['HTTP_HOST'] ??= 'localhost';74+ if ('' === ($server['HTTP_HOST'] ?? '')) {
75+ $server['HTTP_HOST'] = 'localhost';
76+ }
75 77
76 // PHP only parses form bodies into $_POST for POST; Symfony's createFromGlobals() covers the other body methods.78 // PHP only parses form bodies into $_POST for POST; Symfony's createFromGlobals() covers the other body methods.
77 $post = $files = [];79 $post = $files = [];
modified tests/HttpConverterTest.php +1 -0
@@ -273,6 +273,7 @@ final class HttpConverterTest extends TestCase
273273
274274 self::assertSame('http://localhost/jobs', $request->getUri());
275275 self::assertSame(80, $request->getPort());
276+ self::assertSame('http://localhost/jobs', HttpConverter::toRequest(['path' => '/jobs', 'headers' => ['Host' => '']])->getUri());
276277 }
277278
278279 public function testFunctionResponseFromTextResponse(): void
@@ -273,6 +273,7 @@ final class HttpConverterTest extends TestCase
273 273
274 self::assertSame('http://localhost/jobs', $request->getUri());274 self::assertSame('http://localhost/jobs', $request->getUri());
275 self::assertSame(80, $request->getPort());275 self::assertSame(80, $request->getPort());
276+ self::assertSame('http://localhost/jobs', HttpConverter::toRequest(['path' => '/jobs', 'headers' => ['Host' => '']])->getUri());
276 }277 }
277 278
278 public function testFunctionResponseFromTextResponse(): void279 public function testFunctionResponseFromTextResponse(): void