mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
http: defer reentrant execution of Parser::Execute
PR-URL: https://github.com/nodejs/node/pull/43369 Fixes: https://github.com/nodejs/node/issues/39671 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
8dce6ad7a5
commit
b970634cfe
4 changed files with 65 additions and 73 deletions
37
test/parallel/test-http-parser-multiple-execute.js
Normal file
37
test/parallel/test-http-parser-multiple-execute.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { request } = require('http');
|
||||
const { Duplex } = require('stream');
|
||||
|
||||
let socket;
|
||||
|
||||
function createConnection(...args) {
|
||||
socket = new Duplex({
|
||||
read() {},
|
||||
write(chunk, encoding, callback) {
|
||||
if (chunk.toString().includes('\r\n\r\n')) {
|
||||
this.push('HTTP/1.1 100 Continue\r\n\r\n');
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
const req = request('http://localhost:8080', { createConnection });
|
||||
|
||||
req.on('information', common.mustCall(({ statusCode }) => {
|
||||
assert.strictEqual(statusCode, 100);
|
||||
socket.push('HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n');
|
||||
socket.push(null);
|
||||
}));
|
||||
|
||||
req.on('response', common.mustCall(({ statusCode }) => {
|
||||
assert.strictEqual(statusCode, 200);
|
||||
}));
|
||||
|
||||
req.end();
|
Loading…
Add table
Add a link
Reference in a new issue