Skip to content

Commit

Permalink
Fixed bug with binary files
Browse files Browse the repository at this point in the history
  • Loading branch information
unclechu committed Feb 2, 2014
1 parent 1874991 commit 903a2f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions http-file-server.js
Expand Up @@ -198,7 +198,7 @@ http.createServer(function (req, res) {

function openFile() {
debug && console.log('Opening file "'+fullPath+'" ...');
var stream = fs.createReadStream(fullPath, {
var stream = fs.createReadStream(fullPath, 'binary', {
flags: 'r',
encoding: defEnc,
autoClose: true
Expand Down Expand Up @@ -237,7 +237,7 @@ http.createServer(function (req, res) {

debug && console.log('Reading file "'+fullPath+'" ...');
stream.on('data', function (chunk) {
res.write(chunk);
res.write(chunk, 'binary');
});

stream.on('error', function (err) {
Expand Down

0 comments on commit 903a2f0

Please sign in to comment.