Created
September 13, 2010 14:44
-
-
Save muellerkyle/577389 to your computer and use it in GitHub Desktop.
Small change to Connect staticProvider.js for SSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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