fiddle with nodejs streams, see Golo's presentation https://www.youtube.com/watch?v=QgEuZ52OZtU
mocha dependency, bit ugly (global install may be nicer). Call via: node_modules\.bin\mocha constraints.test.js
use streams instead of readfile
for example you can use gzip as a pipe in between: the stream reader reads the file into the pipe, passes this data to the gzip module and the gzip passes it to the http response
rename first example
prime number example for streams: a readstream that returns prime numbers. the stream's data is supplied into a webserver response but has to be converted from the binary buffer data (floating point numbers) into a string (so you can't just pipe the readstream onto the http output stream)