mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
d4e365f606
Node.js seems to change how it is uploaded based on the method, but HTTP doesn't make any distinction. Co-authored-by: Austin Wright <aaa@bzfx.net> Co-authored-by: Lenvin Gonsalves <lenvingonsalves@gmail.com> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: https://github.com/nodejs/node/pull/34066 Refs: https://github.com/nodejs/node/issues/27880 Reviewed-By: James M Snell <jasnell@gmail.com>
31 lines
862 B
JavaScript
31 lines
862 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
const data = 'PUT / HTTP/1.1\r\n\r\n';
|
|
|
|
const server = http.createServer(common.mustCall(function(req, res) {
|
|
req.on('data', function(chunk) {
|
|
assert.strictEqual(chunk, Buffer.from(data));
|
|
});
|
|
res.setHeader('Content-Type', 'text/plain');
|
|
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
|
if (req.rawHeaders[i].toLowerCase() === 'host') continue;
|
|
if (req.rawHeaders[i].toLowerCase() === 'connection') continue;
|
|
res.write(`${req.rawHeaders[i]}: ${req.rawHeaders[i + 1]}\r\n`);
|
|
}
|
|
res.end();
|
|
})).unref();
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const req = http.request({ method: 'DELETE', port }, function(res) {
|
|
res.resume();
|
|
});
|
|
|
|
req.write(data);
|
|
req.end();
|
|
}));
|