Skip to content

Don't use fs.readFile in sendFile() method #7

Description

@indexzero

https://github.com/Pita/etherpad-lite/blob/master/node/server.js#L74

This is a bad idea because you're not sending any data to the request until the entire file is read. You could use the fs.createReadStream() and .pipe() APIs directly:

http://nodejs.org/docs/v0.4.7/api/fs.html#fs.createReadStream
http://nodejs.org/docs/v0.4.7/api/streams.html#stream.pipe

Or better yet, I would suggest using node-static instead. This is a battle-hardened static file server for node.js that we use everyday in production at Nodejitsu.

https://github.com/cloudhead/node-static

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions