From f4fd6aabccd05c320f0f1db9db34db3509a47e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Jensen?= Date: Fri, 19 Jan 2024 20:37:10 +0100 Subject: [PATCH] Allow repeated headers when pulling HTTP messages --- docs/Changelog.md | 4 ++++ src/Http/HttpHandler.php | 2 +- src/Middleware/Callback.php | 5 +---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 218d80d..1d5b703 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -6,6 +6,10 @@ > PHP version `^8.0` +### `2.1.2` + + * Allow repeated headers when pulling HTTP messages (@sirn-se) + ### `2.1.1` * Fix issue with falsy but valid HTTP headers (@axklim) diff --git a/src/Http/HttpHandler.php b/src/Http/HttpHandler.php index 5619059..745a33a 100644 --- a/src/Http/HttpHandler.php +++ b/src/Http/HttpHandler.php @@ -85,7 +85,7 @@ public function pull(): MessageInterface foreach ($headers as $header) { $parts = explode(':', $header, 2); if (count($parts) == 2) { - $message = $message->withHeader($parts[0], $parts[1]); + $message = $message->withAddedHeader($parts[0], $parts[1]); } } if ($message instanceof Request) { diff --git a/src/Middleware/Callback.php b/src/Middleware/Callback.php index d2d897f..2c65ec4 100644 --- a/src/Middleware/Callback.php +++ b/src/Middleware/Callback.php @@ -16,10 +16,7 @@ }; use Stringable; use WebSocket\Connection; -use WebSocket\Http\{ - HttpHandler, - Message as HttpMessage -}; +use WebSocket\Http\Message as HttpMessage; use WebSocket\Message\Message; use WebSocket\Trait\StringableTrait;