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 <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 20, 2017
1 parent 8fc1969 commit f9adf51
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
@@ -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() {
Expand All @@ -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.