Permalink
Browse files

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>
  • Loading branch information...
mithunsasidharan authored and gibfahn committed Nov 27, 2017
1 parent 0fa2f39 commit 8908cd6cc171c963fdafa9e8caa787bd9a7576c3
Showing with 3 additions and 2 deletions.
  1. +3 −2 test/parallel/test-http-response-splitting.js
@@ -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' +
@@ -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(() => {
@@ -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, () => {

0 comments on commit 8908cd6

Please sign in to comment.