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 1866b05

Browse filesBrowse files
mithunsasidharanMylesBorins
authored andcommitted
test: refactored test-http-response-splitting to use countdown
PR-URL: #17348 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent ee1c95f commit 1866b05
Copy full SHA for 1866b05

File tree

Expand file treeCollapse file tree

1 file changed

+3
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-2
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-response-splitting.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-response-splitting.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const http = require('http');
55
const net = require('net');
66
const url = require('url');
77
const assert = require('assert');
8+
const Countdown = require('../common/countdown');
89

910
// Response splitting example, credit: Amit Klein, Safebreach
1011
const str = '/welcome?lang=bar%c4%8d%c4%8aContent­Length:%200%c4%8d%c4%8a%c' +
@@ -18,6 +19,7 @@ const x = 'fooഊSet-Cookie: foo=barഊഊ<script>alert("Hi!")</script>';
1819
const y = 'foo⠊Set-Cookie: foo=bar';
1920

2021
let count = 0;
22+
const countdown = new Countdown(3, () => server.close());
2123

2224
function test(res, code, key, value) {
2325
const header = { [key]: value };
@@ -46,8 +48,7 @@ const server = http.createServer((req, res) => {
4648
default:
4749
assert.fail('should not get to here.');
4850
}
49-
if (count === 3)
50-
server.close();
51+
countdown.dec();
5152
res.end('ok');
5253
});
5354
server.listen(0, () => {

0 commit comments

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