Permalink
Browse files

test: use common.mustCall in test-http-malformed-request

PR-URL: #17439
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
mithunsasidharan authored and gibfahn committed Dec 3, 2017
1 parent 8fc1969 commit f9adf51744f3465e8ffe283a38d03d24c740553c
Showing with 4 additions and 13 deletions.
  1. +4 −13 test/parallel/test-http-malformed-request.js
@@ -1,25 +1,20 @@
'use strict';
require('../common');
const assert = require('assert');
const common = require('../common');
const net = require('net');
const http = require('http');
const url = require('url');
// Make sure no exceptions are thrown when receiving malformed HTTP
// requests.
let nrequests_completed = 0;
const nrequests_expected = 1;
const server = http.createServer(function(req, res) {
const server = http.createServer(common.mustCall((req, res) => {
console.log(`req: ${JSON.stringify(url.parse(req.url))}`);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello World');
res.end();
if (++nrequests_completed === nrequests_expected) server.close();
});
server.close();
}));
server.listen(0);
server.on('listening', function() {
@@ -29,7 +24,3 @@ server.on('listening', function() {
c.end();
});
});
process.on('exit', function() {
assert.strictEqual(nrequests_expected, nrequests_completed);
});

0 comments on commit f9adf51

Please sign in to comment.