Permalink
Browse files

parser: improve parsing of multiple responses in one chunk

  • Loading branch information...
1 parent 0fe9cac commit daf75a944440c250db384ee8ba6babb868859e9d @mscdex committed Jul 31, 2013
Showing with 3 additions and 5 deletions.
  1. +3 −5 lib/parser.js
View
@@ -32,11 +32,9 @@ Parser.prototype._write = function(chunk, encoding, cb) {
while (m = RE_RES_END.exec(this._buffer)) {
// support multiple terminating responses in the buffer
- if (m.index) {
- rest = this._buffer.substring(m.index + m[0].length);
- if (rest.length)
- this._buffer = this._buffer.substring(0, m.index + m[0].length);
- }
+ rest = this._buffer.substring(m.index + m[0].length);
+ if (rest.length)
+ this._buffer = this._buffer.substring(0, m.index + m[0].length);
debug&&debug('[parser] < ' + inspect(this._buffer));

0 comments on commit daf75a9

Please sign in to comment.