diff --git a/CHANGELOG.md b/CHANGELOG.md index 4839837..67bb2b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ All notable changes to this package are in this file. The format follows ## [Unreleased] +## [1.2.0] - 2026-11-22 + +### Changed + +- `new Response()` throws a `ValueError` for an array with keys as a body. Such a body went out as + a stream of its values without the keys; for JSON, pass `json_encode($data)`. +- More messages name the way out: a handler that returns a string or an array, `tick()` or + `close()` called from a handler, and the forms of the headers of `Request` and `Response`. A + handler's wrong value is now "returned", a streamed body's wrong chunk "yielded". + ## [1.1.1] - 2026-11-22 ### Changed @@ -51,7 +61,8 @@ response with the FrankenPHP binary, in the form that Chrome receives, and the p `net/http`. The README states the scope and each deliberate difference. The 0.x releases were private. -[Unreleased]: https://github.com/sorge-it/http-server/compare/v1.1.1...HEAD +[Unreleased]: https://github.com/sorge-it/http-server/compare/v1.2.0...HEAD +[1.2.0]: https://github.com/sorge-it/http-server/compare/v1.1.1...v1.2.0 [1.1.1]: https://github.com/sorge-it/http-server/compare/v1.1.0...v1.1.1 [1.1.0]: https://github.com/sorge-it/http-server/compare/v1.0.0...v1.1.0 [1.0.0]: https://github.com/sorge-it/http-server/releases/tag/v1.0.0 diff --git a/README.md b/README.md index 5dab5c4..079d1a8 100644 --- a/README.md +++ b/README.md @@ -714,7 +714,7 @@ class lives in the namespace `SorgeIt\HttpServer\Internal` and can change in any | `Body::read(int $length): string` | at most `$length` bytes; see [The request body](#the-request-body) | `ValueError` for a length below 1; `LogicException` when called while the handler runs, from a fiber other than the server's, such as one you started. Once the handler has returned, a read returns `''` | | `Body::error(): ?string` | null, or the first read error | none | | `(string) $request->body` | the rest of the body as one string, after the whole body has arrived; check `error()` afterwards. Cast it before you pass it to a function such as `json_decode()`: under `strict_types`, a function that accepts a string rejects the object | `LogicException` as for `read()` | -| `new Response(int $status = 200, array $headers = [], string\|iterable $body = '', ?string $file = null, bool $deleteFile = false)` | a response. `$headers` maps a name to a string or a list of strings. `$body` is a string, or an iterable of strings that the server streams as they come. `$file` sends a file instead of a body. A redirect needs its status, such as `new Response(303, ['Location' => '/done'])`; status 0 sets none, and then a `Location` gives 302, as in PHP. A status outside 100 to 999 becomes 500 | `ValueError` for a header value that is not a string, an integer header key, or a body and a file together | +| `new Response(int $status = 200, array $headers = [], string\|iterable $body = '', ?string $file = null, bool $deleteFile = false)` | a response. `$headers` maps a name to a string or a list of strings. `$body` is a string, or an iterable of strings that the server streams as they come. `$file` sends a file instead of a body. A redirect needs its status, such as `new Response(303, ['Location' => '/done'])`; status 0 sets none, and then a `Location` gives 302, as in PHP. A status outside 100 to 999 becomes 500 | `ValueError` for a header value that is not a string, an integer header key, an array with keys as a body, or a body and a file together | | `Response::$status`, `$headers`, `$body`, `$file`, `$deleteFile` | the constructor arguments, as public readonly properties, for a test that checks a handler's response | none | | `new Limits(?int $maxHead = null, ?int $maxBody = null, ?float $idleTimeout = null, ?float $headerTimeout = null)` | the limits and timeouts; name the arguments, such as `new Limits(maxBody: 1024)`. Null selects the default, 0 turns a limit off. Defaults: `maxHead` 16 KiB, `maxBody` none, `idleTimeout` 120 s, `headerTimeout` 10 s; see [Limits and timeouts](#limits-and-timeouts) | `ValueError` for a negative value, or a timeout that is not finite or above 1e8 s | | `ClosedWithErrors::$errors` | the list of `Throwable`s that no `onError` received; the first is also the previous exception | none | diff --git a/src/Internal/Answer.php b/src/Internal/Answer.php index 218c5a1..cffd521 100644 --- a/src/Internal/Answer.php +++ b/src/Internal/Answer.php @@ -62,7 +62,12 @@ private function __construct(public string $head, public array $parts, public bo public static function check(mixed $response): Response { if (! $response instanceof Response) { - throw new UnexpectedValueException('The handler gave '.get_debug_type($response).', not a '.Response::class.'. '.($response === null ? 'Return a Response from every path of the handler.' : 'A handler for a framework converts its response; see "Works with Symfony, Laravel and PSR-15" in the README of sorge-it/http-server.')); + throw new UnexpectedValueException('The handler returned '.get_debug_type($response).', not a '.Response::class.'. '.match (true) { + $response === null => 'Return a Response from every path of the handler.', + is_string($response) => 'Wrap it: new Response(200, [], $body).', + is_array($response) => 'For JSON, return new Response(200, [\'Content-Type\' => \'application/json\'], json_encode($data)).', + default => 'A handler for a framework converts its response; see "Works with Symfony, Laravel and PSR-15" in the README of sorge-it/http-server.', + }); } if ($response->file !== null && (! is_file($response->file) || ! is_readable($response->file))) { @@ -287,7 +292,7 @@ private static function body(iterable $chunks, bool $sent, bool $counted, bool $ private static function chunk(mixed $chunk): string { if (! is_string($chunk)) { - throw new UnexpectedValueException('The body gave '.get_debug_type($chunk).', not a string. A streamed body yields strings; for JSON, pass json_encode($data) as the body.'); + throw new UnexpectedValueException('The streamed body yielded '.get_debug_type($chunk).', not a string. Yield strings; for JSON, pass json_encode($data) as the body.'); } return $chunk; diff --git a/src/Internal/Connection.php b/src/Internal/Connection.php index e93d13e..8e89089 100644 --- a/src/Internal/Connection.php +++ b/src/Internal/Connection.php @@ -322,7 +322,7 @@ public function close(): array // handler suspended itself waits for no read, so it is dropped. if ($fiber instanceof Fiber && $request instanceof Request && $fiber->isSuspended() && $this->parser->waits()) { $length = (int) $request->header('Content-Length'); - $errors[] = [new LogicException(sprintf('The server closed before the body was complete, with %d of %d bytes read', $length - $this->parser->left(), $length)), $request]; + $errors[] = [new LogicException(sprintf('The server closed before the body was complete, with %d of %d bytes read.', $length - $this->parser->left(), $length)), $request]; $this->parser->end('read tcp '.$this->local.'->'.$this->remote.': '.Go::NET_CLOSING); $fiber->resume(); diff --git a/src/Request.php b/src/Request.php index a2b9149..fb5db38 100644 --- a/src/Request.php +++ b/src/Request.php @@ -85,11 +85,11 @@ private function fault(array $headers): ?string $name = (string) $name; if ($name !== strtolower($name)) { - return 'has the name '.addcslashes($name, "\0..\37\177..\377").', which is not lowercase'; + return 'has the name '.addcslashes($name, "\0..\37\177..\377").", which is not lowercase; map each lowercase name to a list of values, such as ['content-type' => ['text/plain']]"; } if (! is_array($values) || ! array_is_list($values)) { - return 'has values of '.addcslashes($name, "\0..\37\177..\377").' that are not a list'; + return 'has values of '.addcslashes($name, "\0..\37\177..\377")." that are not a list; map each lowercase name to a list of values, such as ['content-type' => ['text/plain']]"; } } diff --git a/src/Response.php b/src/Response.php index 4b277e5..c7460b8 100644 --- a/src/Response.php +++ b/src/Response.php @@ -38,6 +38,11 @@ public function __construct( if ($body !== '' && $file !== null) { throw new ValueError(sprintf('%s::__construct(): Argument #3 ($body) must be empty when Argument #4 ($file) is given', self::class)); } + + // A streamed body would send the values without the keys, as `yesAda` for JSON data. + if (is_array($body) && ! array_is_list($body)) { + throw new ValueError(sprintf('%s::__construct(): Argument #3 ($body) must be a list of strings, not an array with keys; for JSON, pass json_encode($data)', self::class)); + } } /** @@ -50,7 +55,7 @@ private function fault(array $headers): ?string { foreach ($headers as $name => $values) { if (is_int($name)) { - return 'has the key '.$name.', which is not a header name'; + return 'has the key '.$name.", which is not a header name; map each name to its value, such as ['X-Foo' => 'bar']"; } // Not `(array)`: it makes an object the list of its properties. diff --git a/src/Server.php b/src/Server.php index 2f8d38b..3d0dc3b 100644 --- a/src/Server.php +++ b/src/Server.php @@ -209,7 +209,7 @@ public function tick(float $seconds): void } if ($this->busy()) { - throw new LogicException('tick() is already running, or close() resumes a handler. A tick now would answer later requests before the one in progress.'); + throw new LogicException('tick() is already running, or close() resumes a handler. A tick now would answer later requests before the one in progress. Return from the handler, and call tick() and close() from the test.'); } $this->ticking = true; @@ -234,7 +234,7 @@ public function tick(float $seconds): void public function close(): void { if ($this->busy()) { - throw new LogicException('close() was called during tick(), or from a handler that close() resumes. A close now would end the request in progress.'); + throw new LogicException('close() was called during tick(), or from a handler that close() resumes. A close now would end the request in progress. Return from the handler, and call tick() and close() from the test.'); } $this->closing = true; diff --git a/tests/Files/FilesTest.php b/tests/Files/FilesTest.php index 7090f77..82ff93c 100644 --- a/tests/Files/FilesTest.php +++ b/tests/Files/FilesTest.php @@ -212,7 +212,7 @@ function lockedFile(string $content): string expect(feof($client))->toBeTrue() ->and($errors)->toBe([ - 'LogicException: The server closed before the body was complete, with 3 of 10 bytes read', + 'LogicException: The server closed before the body was complete, with 3 of 10 bytes read.', 'RuntimeException: read abc', ]); } finally { diff --git a/tests/FrankenPhp/FrankenPhpTest.php b/tests/FrankenPhp/FrankenPhpTest.php index 91785e7..ad7b4f7 100644 --- a/tests/FrankenPhp/FrankenPhpTest.php +++ b/tests/FrankenPhp/FrankenPhpTest.php @@ -236,7 +236,7 @@ function frankenPhpCases(): array [$answer, $errors] = withDisplayErrors('0', static fn (): array => failed(static fn (): Response => new Response(body: new ArrayIterator([1])), "GET / HTTP/1.1\r\nHost: a\r\nConnection: close\r\n\r\n")); expect($answer)->toStartWith("HTTP/1.1 500 Internal Server Error\r\n")->toContain("\r\nContent-Length: 0\r\n") - ->and($errors)->toBe(['UnexpectedValueException: The body gave int, not a string. A streamed body yields strings; for JSON, pass json_encode($data) as the body.']); + ->and($errors)->toBe(['UnexpectedValueException: The streamed body yielded int, not a string. Yield strings; for JSON, pass json_encode($data) as the body.']); }); it('gives onError each throwable PHP turns into output, once, and answers the next request', function (string $target, string $start): void { diff --git a/tests/Handler/BodyTest.php b/tests/Handler/BodyTest.php index 331399e..76ea5c5 100644 --- a/tests/Handler/BodyTest.php +++ b/tests/Handler/BodyTest.php @@ -120,7 +120,7 @@ expect($seen)->toBeArray() ->and($seen[0] ?? null)->toBe('') ->and($seen[1] ?? null)->toMatch('/^read tcp \S+->\S+: use of closed network connection$/') - ->and($errors)->toBe(['LogicException: The server closed before the body was complete, with 0 of 5 bytes read']); + ->and($errors)->toBe(['LogicException: The server closed before the body was complete, with 0 of 5 bytes read.']); } finally { fclose($client); } @@ -145,7 +145,7 @@ $server->close(); expect($calls)->toBe([ - ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read', '/upload?x=1', [[], []]], + ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read.', '/upload?x=1', [[], []]], ['RuntimeException: read abc', '/upload?x=1', [[], []]], ]) ->and(converse($server, $client))->toBe("\n"); @@ -162,8 +162,8 @@ try { expect(converse($server, $client, "PUT /upload?x=1 HTTP/1.1\r\nHost: a\r\nContent-Length: 10\r\n\r\nabc"))->toBe('') ->and(closedWithErrors($server))->toBe([ - ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read', 'RuntimeException: read abc'], - 'The server closed with 2 errors that no onError callback received; ClosedWithErrors::$errors lists each one. Fix the handler, or let each request finish before close(). To fail the test at the error instead of at close(), pass onError: static fn (Throwable $e): never => throw $e; a test that expects the error passes an onError that records it. The first, from PUT /upload?x=1: The server closed before the body was complete, with 3 of 10 bytes read', + ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read.', 'RuntimeException: read abc'], + 'The server closed with 2 errors that no onError callback received; ClosedWithErrors::$errors lists each one. Fix the handler, or let each request finish before close(). To fail the test at the error instead of at close(), pass onError: static fn (Throwable $e): never => throw $e; a test that expects the error passes an onError that records it. The first, from PUT /upload?x=1: The server closed before the body was complete, with 3 of 10 bytes read.', true, ]) ->and($server->streams())->toBe([[], []]) @@ -182,8 +182,8 @@ try { expect(converse($server, $client, "POST /early HTTP/1.1\r\nHost: a\r\nContent-Length: 10\r\n\r\nabc"))->toBe('') ->and(closedWithErrors($server))->toBe([ - ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read'], - 'The server closed with 1 error that no onError callback received; ClosedWithErrors::$errors lists each one. Fix the handler, or let each request finish before close(). To fail the test at the error instead of at close(), pass onError: static fn (Throwable $e): never => throw $e; a test that expects the error passes an onError that records it. The first, from POST /early: The server closed before the body was complete, with 3 of 10 bytes read', + ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read.'], + 'The server closed with 1 error that no onError callback received; ClosedWithErrors::$errors lists each one. Fix the handler, or let each request finish before close(). To fail the test at the error instead of at close(), pass onError: static fn (Throwable $e): never => throw $e; a test that expects the error passes an onError that records it. The first, from POST /early: The server closed before the body was complete, with 3 of 10 bytes read.', true, ]); } finally { @@ -210,8 +210,8 @@ try { expect(converse($server, $client, "PUT /upload HTTP/1.1\r\nHost: a\r\nContent-Length: 10\r\n\r\nabc"))->toBe('') ->and(closedWithErrors($server))->toBe([ - ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read'], - 'The server closed with 1 error that no onError callback received; ClosedWithErrors::$errors lists each one. Fix the handler, or let each request finish before close(). To fail the test at the error instead of at close(), pass onError: static fn (Throwable $e): never => throw $e; a test that expects the error passes an onError that records it. The first, from PUT /upload: The server closed before the body was complete, with 3 of 10 bytes read', + ['LogicException: The server closed before the body was complete, with 3 of 10 bytes read.'], + 'The server closed with 1 error that no onError callback received; ClosedWithErrors::$errors lists each one. Fix the handler, or let each request finish before close(). To fail the test at the error instead of at close(), pass onError: static fn (Throwable $e): never => throw $e; a test that expects the error passes an onError that records it. The first, from PUT /upload: The server closed before the body was complete, with 3 of 10 bytes read.', true, ]) ->and($caught)->toStartWith('LogicException: '.$message); diff --git a/tests/Handler/HandlerTest.php b/tests/Handler/HandlerTest.php index d3456c6..bc43522 100644 --- a/tests/Handler/HandlerTest.php +++ b/tests/Handler/HandlerTest.php @@ -13,8 +13,11 @@ ->and($errors)->toHaveCount(1) ->and($errors[0] ?? '')->toContain($message); })->with([ - 'null' => [static fn (Request $request): mixed => $request->path() === '/bad' ? null : new Response(200, [], 'ok'), 'The handler gave null, not a SorgeIt\\HttpServer\\Response. Return a Response from every path of the handler.'], - 'a string' => [static fn (Request $request): mixed => $request->path() === '/bad' ? 'text' : new Response(200, [], 'ok'), 'The handler gave string, not a SorgeIt\\HttpServer\\Response. A handler for a framework converts its response; see "Works with Symfony, Laravel and PSR-15" in the README of sorge-it/http-server.'], + 'null' => [static fn (Request $request): mixed => $request->path() === '/bad' ? null : new Response(200, [], 'ok'), 'The handler returned null, not a SorgeIt\\HttpServer\\Response. Return a Response from every path of the handler.'], + 'a string' => [static fn (Request $request): mixed => $request->path() === '/bad' ? 'text' : new Response(200, [], 'ok'), 'The handler returned string, not a SorgeIt\\HttpServer\\Response. Wrap it: new Response(200, [], $body).'], + 'an array' => [static fn (Request $request): mixed => $request->path() === '/bad' ? ['ok' => true] : new Response(200, [], 'ok'), 'The handler returned array, not a SorgeIt\\HttpServer\\Response. For JSON, return new Response(200, [\'Content-Type\' => \'application/json\'], json_encode($data)).'], + 'an object' => [static fn (Request $request): mixed => $request->path() === '/bad' ? new stdClass : new Response(200, [], 'ok'), 'The handler returned stdClass, not a SorgeIt\\HttpServer\\Response. A handler for a framework converts its response; see "Works with Symfony, Laravel and PSR-15" in the README of sorge-it/http-server.'], + 'a body that is an array with keys' => [static fn (Request $request): Response => $request->path() === '/bad' ? new Response(200, [], ['ok' => 'yes']) : new Response(200, [], 'ok'), 'ValueError: '.Response::class.'::__construct(): Argument #3 ($body) must be a list of strings, not an array with keys; for JSON, pass json_encode($data)'], // @phpstan-ignore argument.type (a handler result the server cannot send) 'a header value that is a number' => [static fn (Request $request): Response => $request->path() === '/bad' ? new Response(200, ['X-Count' => 5]) : new Response(200, [], 'ok'), 'ValueError: '.Response::class.'::__construct(): Argument #2 ($headers) has a value of X-Count that is not a string'], // @phpstan-ignore argument.type (a handler result the server cannot send) @@ -24,7 +27,7 @@ // @phpstan-ignore argument.type (a handler result the server cannot send) 'a header value that is an object with a property' => [static fn (Request $request): Response => $request->path() === '/bad' ? new Response(200, ['X-Arr' => (object) ['v']]) : new Response(200, [], 'ok'), 'Argument #2 ($headers) has a value of X-Arr that is not a string'], // @phpstan-ignore argument.type (a handler result the server cannot send) - 'a header without a name' => [static fn (Request $request): Response => $request->path() === '/bad' ? new Response(200, ['X: y']) : new Response(200, [], 'ok'), 'Argument #2 ($headers) has the key 0, which is not a header name'], + 'a header without a name' => [static fn (Request $request): Response => $request->path() === '/bad' ? new Response(200, ['X: y']) : new Response(200, [], 'ok'), 'Argument #2 ($headers) has the key 0, which is not a header name; map each name to its value, such as [\'X-Foo\' => \'bar\']'], ]); it('takes header values with keys in their order, also where a warning throws', function (): void { @@ -97,8 +100,8 @@ 'a value that is an object' => [['X' => new stdClass], 'has a value of X that is not a string'], 'a value that is a number, of a name with a line break' => [["X\nY" => 1], 'has a value of X\nY that is not a string'], 'values with keys, one an integer' => [['X' => ['a' => 'b', 'c' => 2]], 'has a value of X that is not a string'], - 'an integer key, as of a list' => [['X: y'], 'has the key 0, which is not a header name'], - 'a name of digits, which PHP makes an integer key' => [['123' => 'a'], 'has the key 123, which is not a header name'], + 'an integer key, as of a list' => [['X: y'], "has the key 0, which is not a header name; map each name to its value, such as ['X-Foo' => 'bar']"], + 'a name of digits, which PHP makes an integer key' => [['123' => 'a'], "has the key 123, which is not a header name; map each name to its value, such as ['X-Foo' => 'bar']"], ]); it('refuses a request with a header name that is not lowercase, or values that are not a list, with a ValueError', function (array $headers, string $fault): void { @@ -106,10 +109,10 @@ expect(static fn (): Request => new Request('GET', '/', $headers)) ->toThrow(ValueError::class, Request::class.'::__construct(): Argument #3 ($headers) '.$fault); })->with([ - 'a name with an uppercase letter' => [['Content-Type' => ['a']], 'has the name Content-Type, which is not lowercase'], - 'a name with a line break' => [["x\nY" => ['a']], 'has the name x\nY, which is not lowercase'], - 'values that are a string' => [['x-a' => 'a'], 'has values of x-a that are not a list'], - 'values with keys' => [['x-a' => ['k' => 'a']], 'has values of x-a that are not a list'], + 'a name with an uppercase letter' => [['Content-Type' => ['a']], "has the name Content-Type, which is not lowercase; map each lowercase name to a list of values, such as ['content-type' => ['text/plain']]"], + 'a name with a line break' => [["x\nY" => ['a']], 'has the name x\nY, which is not lowercase; map each lowercase name to a list of values, such as [\'content-type\' => [\'text/plain\']]'], + 'values that are a string' => [['x-a' => 'a'], "has values of x-a that are not a list; map each lowercase name to a list of values, such as ['content-type' => ['text/plain']]"], + 'values with keys' => [['x-a' => ['k' => 'a']], "has values of x-a that are not a list; map each lowercase name to a list of values, such as ['content-type' => ['text/plain']]"], ]); it('takes a request without headers, and a name of digits, which PHP makes an integer key', function (): void { @@ -179,7 +182,7 @@ public function handle(Request $request): Response expect(substr_count($answer, 'HTTP/1.1 500 '))->toBe(2) ->and($calls)->toBe([ [LogicException::class, 'broken', '/throws', 1], - [UnexpectedValueException::class, 'The handler gave null, not a SorgeIt\\HttpServer\\Response. Return a Response from every path of the handler.', '/null', 1], + [UnexpectedValueException::class, 'The handler returned null, not a SorgeIt\\HttpServer\\Response. Return a Response from every path of the handler.', '/null', 1], ]); }); @@ -305,8 +308,8 @@ public function record(Throwable $throwable): void } expect($thrown)->toBe([ - ['RuntimeException: onError: /first: The server closed before the body was complete, with 1 of 5 bytes read', true, true, false], - ['RuntimeException: onError: /second: The server closed before the body was complete, with 1 of 5 bytes read', true, true, false], + ['RuntimeException: onError: /first: The server closed before the body was complete, with 1 of 5 bytes read.', true, true, false], + ['RuntimeException: onError: /second: The server closed before the body was complete, with 1 of 5 bytes read.', true, true, false], null, ]); } finally { diff --git a/tests/Responses/ResponsesTest.php b/tests/Responses/ResponsesTest.php index 4e73cf4..7dd4415 100644 --- a/tests/Responses/ResponsesTest.php +++ b/tests/Responses/ResponsesTest.php @@ -149,7 +149,7 @@ ->and($errors)->toBe([$message, $message]); })->with([ 'a throw' => [static fn (): Generator => yield throw new RuntimeException('first'), 'RuntimeException: first'], - 'an integer' => [static fn (): array => [1], 'UnexpectedValueException: The body gave int, not a string. A streamed body yields strings; for JSON, pass json_encode($data) as the body.'], + 'an integer' => [static fn (): array => [1], 'UnexpectedValueException: The streamed body yielded int, not a string. Yield strings; for JSON, pass json_encode($data) as the body.'], ]); it('ends the body for a later chunk that throws, as FrankenPHP for a script that throws, and gives onError the throwable', function (): void { @@ -171,7 +171,7 @@ expect(substr_count($answer, 'HTTP/1.1 '))->toBe(1) ->and($answer)->toEndWith("\r\n\r\n2\r\nok\r\n\n") - ->and($errors)->toBe(['UnexpectedValueException: The body gave int, not a string. A streamed body yields strings; for JSON, pass json_encode($data) as the body.']); + ->and($errors)->toBe(['UnexpectedValueException: The streamed body yielded int, not a string. Yield strings; for JSON, pass json_encode($data) as the body.']); }); it('gives onError the LogicException of a close() from a later chunk, and stays open', function (): void { diff --git a/tests/Transport/TransportTest.php b/tests/Transport/TransportTest.php index 400c092..ff4f269 100644 --- a/tests/Transport/TransportTest.php +++ b/tests/Transport/TransportTest.php @@ -218,7 +218,7 @@ function hasIpv6Loopback(): bool expect(substr_count($answers[0], '<'.$names[0].'|>'))->toBe(2) ->and($answers[1])->toEndWith('<'.$names[1].'|>') ->and(end($seen))->toBe('<'.$names[2].'|'.$closing.'>01') - ->and($errors)->toBe(['LogicException: The server closed before the body was complete, with 2 of 10 bytes read']) + ->and($errors)->toBe(['LogicException: The server closed before the body was complete, with 2 of 10 bytes read.']) ->and($names[0])->not->toBe($names[1]) ->and($names[0])->toMatch($client === '[::1]' ? '/^\[::1]:\d+$/' : '/^127\.0\.0\.1:\d+$/');