mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

Fixes: https://github.com/nodejs/node/issues/27199 PR-URL: https://github.com/nodejs/node/pull/27325 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
35 lines
804 B
JavaScript
35 lines
804 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const net = require('net');
|
|
|
|
let received = '';
|
|
|
|
const server = http.createServer(function(req, res) {
|
|
res.writeHead(200);
|
|
res.end();
|
|
|
|
req.socket.on('data', function(data) {
|
|
received += data;
|
|
});
|
|
|
|
assert.strictEqual(req.socket.on, req.socket.addListener);
|
|
assert.strictEqual(req.socket.prependListener,
|
|
net.Socket.prototype.prependListener);
|
|
|
|
server.close();
|
|
}).listen(0, function() {
|
|
const socket = net.connect(this.address().port, function() {
|
|
socket.write('PUT / HTTP/1.1\r\n\r\n');
|
|
|
|
socket.once('data', function() {
|
|
socket.end('hello world');
|
|
});
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.strictEqual(received, 'hello world');
|
|
});
|