diff options
author | Matteo Collina <hello@matteocollina.com> | 2018-02-22 16:56:01 +0000 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2018-02-27 12:26:40 +0100 |
commit | 29be1e5f8426b8f58a390847aa94c1f9a6d103f4 (patch) | |
tree | 525af72819d63fb2857040d8589e71b6d5db60a9 /test/parallel/test-http-dump-req-when-res-ends.js | |
parent | 0bff955b6d9e1d3f5b1c0b1b71e68f7c0da33de7 (diff) | |
download | android-node-v8-29be1e5f8426b8f58a390847aa94c1f9a6d103f4.tar.gz android-node-v8-29be1e5f8426b8f58a390847aa94c1f9a6d103f4.tar.bz2 android-node-v8-29be1e5f8426b8f58a390847aa94c1f9a6d103f4.zip |
http: do not replace .read() in IncomingMessage
Remove the req._consumed property, as its use is completely
superseded and not needed anymore. This was being set in the
overridden .read().
PR-URL: https://github.com/nodejs/node/pull/18939
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-http-dump-req-when-res-ends.js')
-rw-r--r-- | test/parallel/test-http-dump-req-when-res-ends.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/parallel/test-http-dump-req-when-res-ends.js b/test/parallel/test-http-dump-req-when-res-ends.js new file mode 100644 index 0000000000..e87dfee96f --- /dev/null +++ b/test/parallel/test-http-dump-req-when-res-ends.js @@ -0,0 +1,54 @@ +'use strict'; + +const common = require('../common'); +const http = require('http'); +const fs = require('fs'); + +const server = http.createServer(function(req, res) { + // this checks if the request gets dumped + req.on('resume', common.mustCall(function() { + console.log('resume called'); + + req.on('data', common.mustCallAtLeast(function(d) { + console.log('data', d); + }, 1)); + })); + + // end is not called as we are just exhausting + // the in-memory buffer + req.on('end', common.mustNotCall); + + // this 'data' handler will be removed when dumped + req.on('data', common.mustNotCall); + + // start sending the response + res.flushHeaders(); + + setTimeout(function() { + res.end('hello world'); + }, common.platformTimeout(100)); +}); + +server.listen(0, function() { + const req = http.request({ + method: 'POST', + port: server.address().port + }); + + // Send the http request without waiting + // for the body + req.flushHeaders(); + + req.on('response', common.mustCall(function(res) { + // pipe the body as soon as we get the headers of the + // response back + fs.createReadStream(__filename).pipe(req); + + res.resume(); + + // wait for the response + res.on('end', function() { + server.close(); + }); + })); +}); |