- fixed OverflowException for large JSON payload received over TCP Socket connections, closed #792

This commit is contained in:
Mark Friedrich
2019-06-02 17:20:34 +02:00
parent 1442288c7a
commit 8a59dca907

View File

@@ -17,6 +17,12 @@ use Clue\React\NDJson;
abstract class AbstractSocket implements SocketInterface {
/**
* max length for JSON data string
* -> throw OverflowException on exceed
*/
const JSON_DECODE_MAX_LENGTH = 65536 * 4;
/**
* @var EventLoop\LoopInterface|null
*/
@@ -195,7 +201,7 @@ abstract class AbstractSocket implements SocketInterface {
// new empty stream for processing JSON
$stream = new Stream\ThroughStream();
$streamDecoded = new NDJson\Decoder($stream, true);
$streamDecoded = new NDJson\Decoder($stream, true, 512, 0, self::JSON_DECODE_MAX_LENGTH);
// promise get resolved on first emit('data')
$promise = Promise\Stream\first($streamDecoded);