Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: set socket.server unconditionally #30571

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/_http_server.js
Expand Up @@ -360,8 +360,7 @@ function connectionListenerInternal(server, socket) {

// Ensure that the server property of the socket is correctly set.
// See https://github.com/nodejs/node/issues/13435
if (socket.server === null)
socket.server = server;
socket.server = server;

// If the user has added a listener to the server,
// request, or response, then it's their responsibility.
Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-http-generic-streams.js
Expand Up @@ -138,3 +138,17 @@ const MakeDuplexPair = require('../common/duplexpair');
req.write(testData);
req.end();
}

// Test 5: The client sends garbage.
{
const server = http.createServer(common.mustNotCall());

const { clientSide, serverSide } = MakeDuplexPair();
server.emit('connection', serverSide);

server.on('clientError', common.mustCall());

// Send something that is not an HTTP request.
clientSide.end(
'I’m reading a book about anti-gravity. It’s impossible to put down!');
}