mcavage/node-restify — pull request #360 by Aldaviva (2013-03-28 03:02:08+00:00)
Title: Piping large response bodies with Gzip in Node 0.10 hangs the response

##### Steps to reproduce

1. Use Node 0.10 (does not occur in 0.8).
2. Set up restify to serve static files with Gzip.
3. Request a file larger than the fs.createReadStream buffer size, which is 65536 by default (I encountered this using a 468K file).
4. Client receives 15 bytes of body content before the connection hangs until timing out.

##### Root cause

1. The static module's fstream writes the first chunk to the Gzip stream.
2. Gzip's write returns false indicating a full Gzip buffer.
3. Later, Gzip's stream emits a drain event, so it is time to write more.
4. Nothing in the restify gzip plugin is listening for this drain event, so the fstream makes no more progress.

##### Proposed fix
* In the gzip plugin, forward the Gzip stream drain event to the response stream.