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 0858587

Browse filesBrowse files
mcollinaBethGriggs
authored andcommitted
http: add regression test for chunked smuggling
PR-URL: nodejs-private/node-private#286 Reviewed-By: Beth Griggs <bgriggs@redhat.com>
1 parent 21a2e55 commit 0858587
Copy full SHA for 0858587

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+43
-0
lines changed
Open diff view settings
Collapse file
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const http = require('http');
5+
const net = require('net');
6+
const assert = require('assert');
7+
8+
// Verify that a request with a space before the content length will result
9+
// in a 400 Bad Request.
10+
11+
const server = http.createServer(common.mustCall((request, response) => {
12+
assert.notStrictEqual(request.url, '/admin');
13+
response.end('hello world');
14+
}), 1);
15+
16+
server.listen(0, common.mustCall(start));
17+
18+
function start() {
19+
const sock = net.connect(server.address().port);
20+
21+
sock.write('' +
22+
'GET / HTTP/1.1\r\n' +
23+
'Host: localhost:8080\r\n' +
24+
'Transfer-Encoding: chunked\r\n' +
25+
'\r\n' +
26+
'2 \n' +
27+
'xx\r\n' +
28+
'4c\r\n' +
29+
'0\r\n' +
30+
'\r\n' +
31+
'GET /admin HTTP/1.1\r\n' +
32+
'Host: localhost:8080\r\n' +
33+
'Transfer-Encoding: chunked\r\n' +
34+
'\r\n' +
35+
'0\r\n' +
36+
'\r\n'
37+
);
38+
39+
sock.resume();
40+
sock.on('end', common.mustCall(function() {
41+
server.close();
42+
}));
43+
}

0 commit comments

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