Skip to content

Commit

Permalink
test: use common.mustCall in test-http-malformed-request
Browse files Browse the repository at this point in the history
PR-URL: #17439
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mithunsasidharan authored and MylesBorins committed Dec 12, 2017
1 parent 0ade488 commit 07fd4cf
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions test/parallel/test-http-malformed-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,22 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'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() {
Expand All @@ -50,7 +45,3 @@ server.on('listening', function() {
c.end();
});
});

process.on('exit', function() {
assert.strictEqual(nrequests_expected, nrequests_completed);
});

0 comments on commit 07fd4cf

Please sign in to comment.