node.js - Is there a way to limit the maximum size of a string? -


i have application in wish limit maximum size of message sent across wire connected client. since theoretical maximum of message in nodejs 1.9gb, never want application allocate big chunk of memory if malicious clients tries send over-sized packet.

how can limit incoming message size, say, 1024 bytes?

each character 1 3 bytes in length. can technically substring string desired length.

var limited = fullstring.substring(0, 1024); 

or can use package : utf8-binary-cutter


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -