Permalink
Browse files

[fix] Wait for `process.nextTick` if the Request has not drained yet

  • Loading branch information...
1 parent a66f40a commit deb8691c9da390933b9ed0fbcf6db9ea026f1ada @indexzero indexzero committed Jan 23, 2012
Showing with 18 additions and 16 deletions.
  1. +18 −16 lib/director/http/index.js
View
@@ -109,24 +109,26 @@ Router.prototype.dispatch = function (req, res, callback) {
}
if (!stream) {
- //
- // If there is no streaming required on any of the functions on the
- // way to `path`, then attempt to parse the fully buffered request stream
- // once it has emitted the `end` event.
- //
- if (req.readable) {
+ process.nextTick(function () {
//
- // If the `http.ServerRequest` is still readable, then await
- // the end event and then continue
+ // If there is no streaming required on any of the functions on the
+ // way to `path`, then attempt to parse the fully buffered request stream
+ // once it has emitted the `end` event.
//
- req.once('end', parseAndInvoke)
- }
- else {
- //
- // Otherwise, just parse the body now.
- //
- parseAndInvoke();
- }
+ if (req.readable) {
+ //
+ // If the `http.ServerRequest` is still readable, then await
+ // the end event and then continue
+ //
+ req.once('end', parseAndInvoke)
+ }
+ else {
+ //
+ // Otherwise, just parse the body now.
+ //
+ parseAndInvoke();
+ }
+ });
}
else {
this.invoke(runlist, thisArg, callback);

0 comments on commit deb8691

Please sign in to comment.