News for hackers. Stuff that matters.
Re:Nginx Unit by Matthias247 on Thursday September 07, 2017 @04:58PM (#15195646)
Do you not allow \n inside your JSON or encode your JSON as base64? If not you might have problems with disambiguating frame ends from line breaks inside frames.

A common way for framing is to prepend each frame with it's encoded length. That's easier, faster and less error-prone than searching for ASCII delimeters.

Re:Nginx Unit by AgentME on Thursday September 07, 2017 @06:18PM (#15196297)
If you do the JSON serialization yourself, there's no reason for newlines to be in the JSON. (Newlines within strings are encoded as \n.)
Re:Nginx Unit by tlb on Friday September 08, 2017 @01:21PM (#15202156)
I'm generating the JSON, either with custom C++ marshaling routines or with JSON.stringify which doesn't include newlines unless you give it extra arguments. I believe that any valid JSON can be converted to a single line by changing any '\n' bytes to ' '. Literal '\n' bytes are not allowed inside strings, and outside strings any whitespace is equivalent.
Re:Nginx Unit by justinsaccount on Thursday September 07, 2017 @06:21PM (#15196328)
a newline is encoded as the two characters "\n" in json and would not be confused with a literal \n (aka \x0a) character