mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
PR-URL: https://github.com/nodejs/node/pull/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>
27 lines
684 B
JavaScript
27 lines
684 B
JavaScript
'use strict';
|
|
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.
|
|
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();
|
|
|
|
server.close();
|
|
}));
|
|
server.listen(0);
|
|
|
|
server.on('listening', function() {
|
|
const c = net.createConnection(this.address().port);
|
|
c.on('connect', function() {
|
|
c.write('GET /hello?foo=%99bar HTTP/1.1\r\n\r\n');
|
|
c.end();
|
|
});
|
|
});
|