Skip to content

Commit

Permalink
test: refactored test-http-response-splitting to use countdown
Browse files Browse the repository at this point in the history
PR-URL: #17348
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
mithunsasidharan authored and gibfahn committed Dec 20, 2017
1 parent a3d218d commit 279d844
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-http-response-splitting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const http = require('http');
const net = require('net');
const url = require('url');
const assert = require('assert');
const Countdown = require('../common/countdown');

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

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

function test(res, code, header) {
assert.throws(() => {
Expand All @@ -40,8 +42,7 @@ const server = http.createServer((req, res) => {
default:
assert.fail('should not get to here.');
}
if (count === 3)
server.close();
countdown.dec();
res.end('ok');
});
server.listen(0, () => {
Expand Down

0 comments on commit 279d844

Please sign in to comment.