-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: defer reentrant execution of Parser::Execute
PR-URL: #43369 Fixes: #39671 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
1 parent
5fd26da
commit 58eebaf
Showing
4 changed files
with
65 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters