Serving HTTP/1.0 responses with Node.JS (unknown content length, chunked transfer encoding)

For my purposes, I found an easy way to disable the forced usage of chunked, using an undocumented property of the response object:

response.useChunkedEncodingByDefault = false;

It's that simple. Of course, relying on this property to be available for future versions of Node.js isn't the best. Perhaps there is a better solution, but this works for me for now.


Forcing non-chunked responses, the right way

There's a supported way of turning off chunked encoding: you simply need to remove the Transfer-Encoding header using request.removeHeader(name):

response.removeHeader('transfer-encoding');

Node.js will respect no matter what. There's even a test to prevent someone from accidentally changing this behavior, so I think it's pretty safe to use.

So you can just stick with attempt #1, but doing it as described above.