In the example below an HTTP server doesn't read the the request body, but returns the response immediately. If the client sends large data (e.g. 10,000,000 bytes) ECONNRESET error is emitted at client-side but on small data (e.g. 1,000,000 bytes) the programs runs silently.
var crypto = require('crypto'),
http = require('http')
var port = 8080
var server = http.createServer((req, res) => {
res.end(crypto.randomBytes(10000))
})
server.listen(port, () => {
var req = http.request({
port: port,
method: 'post',
})
req.end(crypto.randomBytes(10000000)) // <- play this value, remove zeros, then add
})
I think the client still sends data after receiving the response. Thus the client violates HTTP request syntax and the connection gets reset. Is this the expected behavior? If so what's the correct way of handling this?
In the example below an HTTP server doesn't read the the request body, but returns the response immediately. If the client sends large data (e.g. 10,000,000 bytes) ECONNRESET error is emitted at client-side but on small data (e.g. 1,000,000 bytes) the programs runs silently.
I think the client still sends data after receiving the response. Thus the client violates HTTP request syntax and the connection gets reset. Is this the expected behavior? If so what's the correct way of handling this?