Skip to content

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

@indexzero

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions