Closed jchip closed 3 years ago
the issue is because of Content-Length
. I have this:
mitm.on("request", (req, res) => {
verifyRequestHeaders(req);
res.writeHead(401, {
"Content-Type": "application/json; charset=utf-8",
"Content-Length": 50
});
res.end(JSON.stringify({ error: "Invalid login or password." }));
});
turns out the data changed but length didn't update and node.js 14 throw ReadError now.
Hey! I'm glad you found the problem already. For the record, yep, Mitm.js should be fully supported on all Node versions all the way back to 0.10 and up to 16 and beyond. :)
Btw, I don't think you need to set the Content-Length
header manually. I believe Node.js does it for you in your example or just defaults to chunked-encoding, which should be supported by whichever library you were using to do the request in the first place.
I have some old project using this for unit tests but they are now failing with timeout on node.js 14.