-
Hi. const net = require('net');
const app = require('uWebSockets.js').App();
const port = 9001;
app.post('/test', (res, req) => {
res.onAborted(() => {
res.aborted = true;
});
res.writeStatus('413');
res.end();
res.close();
});
app.listen(port, () => {});
const client = net.createConnection({ port }, () => {
client.write(
'POST /test HTTP/1.1\r\n' +
'host: localhost\r\n' +
'content-length: 4\r\n\r\nnull'
);
});
client.on('data', data => {
console.log(data.toString());
client.end();
});
client.on('end', data => {
console.log('Disconnected from server');
}); Output
This behaviour by design, or is bug? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
This is design you cannot do anything with a response you already ended |
Beta Was this translation helpful? Give feedback.
-
I want to close the connection so as not to read request body. Or can I respond with an error code and not close the connections, and the next requests in this connection will come normally? |
Beta Was this translation helpful? Give feedback.
-
That would most probably be against http standard and is not supported |
Beta Was this translation helpful? Give feedback.
That would most probably be against http standard and is not supported