Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ccf9038

Browse filesBrowse files
sam-githubtargos
authored andcommitted
test: check that --insecure-http-parser works
Test that using --insecure-http-parser will disable validation of invalid characters in HTTP headers. See: - #30567 PR-URL: #31253 Backport-PR-URL: #30473 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 3a7a3be commit ccf9038
Copy full SHA for ccf9038

File tree

Expand file treeCollapse file tree

2 files changed

+70
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+70
-0
lines changed
Open diff view settings
Collapse file
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Flags: --insecure-http-parser --http-parser=legacy
2+
3+
'use strict';
4+
const common = require('../common');
5+
const assert = require('assert');
6+
const http = require('http');
7+
const net = require('net');
8+
9+
const server = http.createServer(function(req, res) {
10+
assert.strictEqual(req.headers['content-type'], 'text/te\bt');
11+
req.pipe(res);
12+
});
13+
14+
server.listen(0, common.mustCall(function() {
15+
const bufs = [];
16+
const client = net.connect(
17+
this.address().port,
18+
function() {
19+
client.write(
20+
'GET / HTTP/1.1\r\n' +
21+
'Content-Type: text/te\x08t\r\n' +
22+
'Connection: close\r\n\r\n');
23+
}
24+
);
25+
client.on('data', function(chunk) {
26+
bufs.push(chunk);
27+
});
28+
client.on('end', common.mustCall(function() {
29+
const head = Buffer.concat(bufs)
30+
.toString('latin1')
31+
.split('\r\n')[0];
32+
assert.strictEqual(head, 'HTTP/1.1 200 OK');
33+
server.close();
34+
}));
35+
}));
Collapse file
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Flags: --insecure-http-parser
2+
3+
'use strict';
4+
const common = require('../common');
5+
const assert = require('assert');
6+
const http = require('http');
7+
const net = require('net');
8+
9+
const server = http.createServer(function(req, res) {
10+
assert.strictEqual(req.headers['content-type'], 'text/te\bt');
11+
req.pipe(res);
12+
});
13+
14+
server.listen(0, common.mustCall(function() {
15+
const bufs = [];
16+
const client = net.connect(
17+
this.address().port,
18+
function() {
19+
client.write(
20+
'GET / HTTP/1.1\r\n' +
21+
'Content-Type: text/te\x08t\r\n' +
22+
'Connection: close\r\n\r\n');
23+
}
24+
);
25+
client.on('data', function(chunk) {
26+
bufs.push(chunk);
27+
});
28+
client.on('end', common.mustCall(function() {
29+
const head = Buffer.concat(bufs)
30+
.toString('latin1')
31+
.split('\r\n')[0];
32+
assert.strictEqual(head, 'HTTP/1.1 200 OK');
33+
server.close();
34+
}));
35+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.