benjaminws / stomp-js

Implementation of the STOMP protocol in node.js
BSD 3-Clause "New" or "Revised" License
87 stars 47 forks source link

pipelined frames do not work #46

Open teknopaul opened 7 years ago

teknopaul commented 7 years ago

The on('data') handler has apparent spec violation and subsequent fix that introduces a regression.

The body is then followed by the NULL octet. The examples in this document will use ^@, control-@ in ASCII, to represent the NULL octet. The NULL octet can be optionally followed by multiple EOLs.

    var frames = buffer.split('\0\n'); 

A fix was added that breaks pipelined frames, if frames arrive with mixed \0 and \0\n

    // Temporary fix : NULL,LF is not a guranteed standard, the LF is optional, so lets deal with it.  (Rauls)
    if (frames.length == 1) {  // N.B. == 1means only it the previous split did nothing.
        frames = buffer.split('\0');
    }

Side note: \0 is valid inside MESSAGE data if content-length was provided. But I guess thats a bigger issue.Its OK thatn stomp.js does not support binary. Should be in the docs tho.

I think just

var frames = buffer.split('\0');

Should suffice, I tested that and it seems OK.

Mixed \0 and \0\n terminations occur when \n heartbeats are added between frames that then get buffered.