Skip to content

Instantly share code, notes, and snippets.

@muellerkyle
Created September 13, 2010 14:44
Show Gist options
  • Save muellerkyle/577389 to your computer and use it in GitHub Desktop.
Save muellerkyle/577389 to your computer and use it in GitHub Desktop.
Small change to Connect staticProvider.js for SSL
// Serve the file directly using buffers
function onRead(err, data) {
if (err) return next(err);
// Zero length buffers act funny, use a string
if (data.length === 0) data = '';
res.writeHead(200, {
"Content-Type": utils.mime.type(filename),
"Content-Length": data.length,
"Last-Modified": stat.mtime.toUTCString(),
"Cache-Control": "public max-age=" + maxAge
});
// muellerkyle: Changed from: res.end(data);
res.write(data);
res.end();
}
// muellerKyle: Added switch and encoding to fs.readFile call.
var encoding = 'utf8';
switch (path.extname(filename)) {
case '.png':
case '.gif':
case '.jpg':
encoding = undefined;
break;
}
fs.readFile(filename, encoding, onRead);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment