node/test/parallel/test-http-server-method.query.js
Paolo Insogna 65c8380a5a http: correctly translate HTTP method
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>
2024-05-04 08:56:28 -07:00

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();
}));