test: refactored test-http-response-splitting to use countdown
PR-URL: https://github.com/nodejs/node/pull/17348 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
5282f969c0
commit
0f3fd79ee9
@ -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%8aContentLength:%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, key, value) {
|
||||
const header = { [key]: value };
|
||||
@ -46,8 +48,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, () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user