From c325696fe8d8819310346297c293b99de8cf355d Mon Sep 17 00:00:00 2001 From: Levi Wheatcroft Date: Sun, 16 Oct 2016 08:34:42 +0800 Subject: [PATCH] read content-type from response --- lib/node-static.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node-static.js b/lib/node-static.js index 222dc7e..84f3330 100644 --- a/lib/node-static.js +++ b/lib/node-static.js @@ -180,7 +180,7 @@ Server.prototype.serve = function (req, res, callback) { } process.nextTick(function () { - that.servePath(pathname, 200, {}, req, res, finish).on('success', function (result) { + that.servePath(pathname, 200, res._headers, req, res, finish).on('success', function (result) { promise.emit('success', result); }).on('error', function (err) { promise.emit('error'); @@ -344,7 +344,7 @@ Server.prototype.respondNoGzip = function (pathname, status, contentType, _heade }; Server.prototype.respond = function (pathname, status, _headers, files, stat, req, res, finish) { - var contentType = _headers['Content-Type'] || + var contentType = res.getHeader('Content-Type') || mime.lookup(files[0]) || 'application/octet-stream';