Skip to content

Commit 1866b05

Browse files
mithunsasidharanMylesBorins
authored andcommitted
test: refactored test-http-response-splitting to use countdown
PR-URL: #17348 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent ee1c95f commit 1866b05

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const http = require('http');
55
constnet=require('net');
66
consturl=require('url');
77
constassert=require('assert');
8+
constCountdown=require('../common/countdown');
89

910
// Response splitting example, credit: Amit Klein, Safebreach
1011
conststr='/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
consty='foo⠊Set-Cookie: foo=bar';
1920

2021
letcount=0;
22+
constcountdown=newCountdown(3,()=>server.close());
2123

2224
functiontest(res,code,key,value){
2325
constheader={[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)