diff options
author | Fedor Indutny <fedor@indutny.com> | 2016-06-04 00:21:04 -0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2016-06-15 12:50:19 -0400 |
commit | 357f904169c39bbc9c2d8558bbffce2337c83c1b (patch) | |
tree | 2cfa1fb382da4d251cb07dc142f0800bf928074c /lib/_http_incoming.js | |
parent | 1a1ff77feb3ed003e71bcbd066deadcaf9a82652 (diff) | |
download | android-node-v8-357f904169c39bbc9c2d8558bbffce2337c83c1b.tar.gz android-node-v8-357f904169c39bbc9c2d8558bbffce2337c83c1b.tar.bz2 android-node-v8-357f904169c39bbc9c2d8558bbffce2337c83c1b.zip |
http: fix no dumping after `maybeReadMore`
When `maybeReadMore` kicks in on a first bytes of incoming data, the
`req.read(0)` will be invoked and the `req._consuming` will be set to
`true`. This seemingly harmless property leads to a dire consequences:
the server won't call `req._dump()` and the whole HTTP/1.1 pipeline will
hang (single connection).
PR-URL: https://github.com/nodejs/node/pull/7211
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/_http_incoming.js')
-rw-r--r-- | lib/_http_incoming.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js index 6e66ae6d42..4d1c3ea810 100644 --- a/lib/_http_incoming.js +++ b/lib/_http_incoming.js @@ -20,6 +20,13 @@ exports.readStop = readStop; function IncomingMessage(socket) { Stream.Readable.call(this); + // Set this to `true` so that stream.Readable won't attempt to read more + // data on `IncomingMessage#push` (see `maybeReadMore` in + // `_stream_readable.js`). This is important for proper tracking of + // `IncomingMessage#_consuming` which is used to dump requests that users + // haven't attempted to read. + this._readableState.readingMore = true; + this.socket = socket; this.connection = socket; @@ -67,6 +74,8 @@ IncomingMessage.prototype.setTimeout = function(msecs, callback) { IncomingMessage.prototype.read = function(n) { + if (!this._consuming) + this._readableState.readingMore = false; this._consuming = true; this.read = Stream.Readable.prototype.read; return this.read(n); |