Skip to content

Commit a172b95

Browse files
author
Eran Hammer
committed
Change stream payload flush to streams2 api. Closes hapijs#2459
1 parent d5dc3b5 commit a172b95

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎lib/route.js‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,26 @@ internals.payload = function (request, next) {
392392

393393
// Flush out any pending request payload not consumed due to errors or other restrictions
394394

395-
request.raw.req.once('end', function () {
395+
var stream = request.raw.req;
396+
397+
var read = function () {
398+
399+
stream.read();
400+
};
401+
402+
var end = function () {
403+
404+
stream.removeListener('readable', read);
405+
stream.removeListener('error', end);
406+
stream.removeListener('end', end);
396407

397408
request._isPayloadPending = false;
398409
return onParsed(err, parsed);
399-
});
410+
};
400411

401-
request.raw.req.resume();
412+
stream.on('readable', read);
413+
stream.once('error', end);
414+
stream.once('end', end);
402415
});
403416
};
404417

0 commit comments

Comments
 (0)