Skip to content

Commit

Permalink
Generate accept header from request key
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Oct 22, 2023
1 parent f5bb36b commit 4e0ee4d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/WebsocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use Psr\Log\NullLogger;
use Revolt\EventLoop;
use function Amp\delay;
use function Amp\Websocket\generateAcceptFromKey;
use function Amp\Websocket\generateKey;

class WebsocketTest extends AsyncTestCase
{
Expand Down Expand Up @@ -145,7 +147,7 @@ public function createRequest(): Request
{
$headers = [
"host" => ["localhost"],
"sec-websocket-key" => ["x3JJHMbDL1EzLkh9GBhXDw=="],
"sec-websocket-key" => [generateKey()],
"sec-websocket-version" => ["13"],
"upgrade" => ["websocket"],
"connection" => ["upgrade"],
Expand Down Expand Up @@ -178,7 +180,7 @@ public function provideHandshakes(): iterable
[
"upgrade" => ["websocket"],
"connection" => ["upgrade"],
"sec-websocket-accept" => ["HSmrc0sMlYUkAGmm5OPpG2HaGWk="],
"sec-websocket-accept" => [generateAcceptFromKey($request->getHeader('sec-websocket-key'))],
],
];

Expand Down Expand Up @@ -230,7 +232,7 @@ public function provideHandshakes(): iterable
[
"upgrade" => ["websocket"],
"connection" => ["upgrade"],
"sec-websocket-accept" => ["HSmrc0sMlYUkAGmm5OPpG2HaGWk="],
"sec-websocket-accept" => [generateAcceptFromKey($request->getHeader('sec-websocket-key'))],
"sec-websocket-extensions" => ["permessage-deflate; client_max_window_bits=15"],
],
];
Expand All @@ -244,7 +246,7 @@ public function provideHandshakes(): iterable
[
"upgrade" => ["websocket"],
"connection" => ["upgrade"],
"sec-websocket-accept" => ["HSmrc0sMlYUkAGmm5OPpG2HaGWk="],
"sec-websocket-accept" => [generateAcceptFromKey($request->getHeader('sec-websocket-key'))],
],
];
}
Expand Down

0 comments on commit 4e0ee4d

Please sign in to comment.