On long-haul links, the header sometimes doesn't include the padding terminator in the first chunk, so wait until it appears.

This commit is contained in:
Tony Garnock-Jones 2012-05-25 17:10:29 -04:00
parent e5c797ce79
commit 282f60e2c6
1 changed files with 7 additions and 1 deletions

View File

@ -289,7 +289,13 @@
// optional identifier within the server
stream.id = text.substring(0, text.indexOf(";"));
// message.index = text.indexOf(";", stream.id.length + ";".length) + ";".length;
message.index = text.indexOf(";", stream.id.length + 1) + 1;
// tonyg 20120525: If the current chunk doesn't include the end-of-padding marker,
// don't accept the header until it does.
var semiPos = text.indexOf(";", stream.id.length + 1);
if (semiPos < 0) {
return false;
}
message.index = semiPos + 1;
};
handleMessage = stream.options.handleMessage || function(text, message) {
// Response could contain a single message, multiple messages or a fragment of a message