diff --git a/src/Sender/Frontend/ConnectionPool.php b/src/Sender/Frontend/ConnectionPool.php index d354aa58..b4129882 100644 --- a/src/Sender/Frontend/ConnectionPool.php +++ b/src/Sender/Frontend/ConnectionPool.php @@ -15,6 +15,7 @@ use Buggregator\Trap\Traffic\Websocket\Frame; use Buggregator\Trap\Traffic\Websocket\Opcode; use Buggregator\Trap\Traffic\Websocket\StreamReader; +use DateTimeImmutable; use Fiber; use IteratorAggregate; use JsonSerializable; @@ -87,6 +88,7 @@ public function send(Frame $frame): void private function processSocket(StreamClient $stream): void { $pingTimer = null; + $lastPong = new DateTimeImmutable(); foreach (StreamReader::readFrames($stream->getIterator()) as $frame) { // Connection close @@ -99,7 +101,7 @@ private function processSocket(StreamClient $stream): void // Pong using `{}` message if ($frame->content === '{}') { - $stream->sendData($this->packPayload('{}')); + $lastPong = new DateTimeImmutable(); continue; } diff --git a/src/Sender/Frontend/Mapper/HttpRequest.php b/src/Sender/Frontend/Mapper/HttpRequest.php index d13b157d..bd32cf51 100644 --- a/src/Sender/Frontend/Mapper/HttpRequest.php +++ b/src/Sender/Frontend/Mapper/HttpRequest.php @@ -32,7 +32,9 @@ public function map(HttpFrame $frame): Event 'method' => $request->getMethod(), 'uri' => $uri, 'headers' => $request->getHeaders(), - 'body' => (string)$request->getBody(), + 'body' => $request->getParsedBody() === null + ? (string)$request->getBody() + : '', 'query' => $request->getQueryParams(), 'post' => $request->getParsedBody() ?? [], 'cookies' => $request->getCookieParams(),