diff options
author | Roee Kasher <roee@fire.glass> | 2017-01-26 13:58:51 +0200 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-02-02 12:01:13 -0800 |
commit | 3e3bfc57d907332fa51566afe61ab1f54827e8be (patch) | |
tree | a5d3d2563b90b674b29bc77b368542e9d33ad794 /test/parallel/test-http-server-unconsume-consume.js | |
parent | 10b687b58b02fa7c55e06b6bd8fc5bc8ef2e1a7f (diff) | |
download | node-new-3e3bfc57d907332fa51566afe61ab1f54827e8be.tar.gz |
src: unconsume stream fix in internal http impl
When emitting a 'connection' event on a httpServer, the function
connectionListener is called. Then, a new parser is created, and
'consume' method is called on the socket's externalStream. However,
if this stream was already consumed and unconsumed, the process
crashes with a cpp assert from the 'Consume' method in stream_base.h.
This commit makes sure that no SIGABRT will be raised and the process
will stay alive (after emitting the socket).
PR-URL: https://github.com/nodejs/node/pull/11015
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-http-server-unconsume-consume.js')
-rw-r--r-- | test/parallel/test-http-server-unconsume-consume.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/parallel/test-http-server-unconsume-consume.js b/test/parallel/test-http-server-unconsume-consume.js new file mode 100644 index 0000000000..77baff19fe --- /dev/null +++ b/test/parallel/test-http-server-unconsume-consume.js @@ -0,0 +1,22 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); + +const testServer = http.createServer((req, res) => { + common.fail('Should not be called'); + res.end(); +}); +testServer.on('connect', common.mustCall((req, socket, head) => { + socket.write('HTTP/1.1 200 Connection Established' + '\r\n' + + 'Proxy-agent: Node-Proxy' + '\r\n' + + '\r\n'); + // This shouldn't raise an assertion in StreamBase::Consume. + testServer.emit('connection', socket); + testServer.close(); +})); +testServer.listen(0, common.mustCall(() => { + http.request({ + port: testServer.address().port, + method: 'CONNECT' + }, (res) => {}).end(); +})); |