mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
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:
1 parent
0fa2f39457
commit
8908cd6cc1
1 file changed
+3
-2
@@ -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, 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, () => {
|
||||
|
||||
Reference in new issue
Block a user