mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
65c8380a5a
PR-URL: https://github.com/nodejs/node/pull/52701 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
28 lines
669 B
JavaScript
28 lines
669 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { strictEqual } = require('assert');
|
|
const { createServer, request } = require('http');
|
|
|
|
const server = createServer(common.mustCall((req, res) => {
|
|
strictEqual(req.method, 'QUERY');
|
|
res.end('OK');
|
|
}));
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const req = request({ port: server.address().port, method: 'QUERY' }, common.mustCall((res) => {
|
|
strictEqual(res.statusCode, 200);
|
|
|
|
let buffer = '';
|
|
res.setEncoding('utf-8');
|
|
|
|
res.on('data', (c) => buffer += c);
|
|
res.on('end', common.mustCall(() => {
|
|
strictEqual(buffer, 'OK');
|
|
server.close();
|
|
}));
|
|
}));
|
|
|
|
req.end();
|
|
}));
|