diff --git a/index.js b/index.js index 1655053..4836893 100644 --- a/index.js +++ b/index.js @@ -577,10 +577,14 @@ SendStream.prototype.send = function send (path, stat) { // set read options opts.start = offset - opts.end = Math.max(offset, offset + len - 1) + if (len > 0) { + opts.end = Math.max(offset, offset + len - 1) + } // content-length - res.setHeader('Content-Length', len) + if (len > 0) { + res.setHeader('Content-Length', len) + } // HEAD support if (req.method === 'HEAD') { diff --git a/test/send.js b/test/send.js index b824282..2f26e12 100644 --- a/test/send.js +++ b/test/send.js @@ -35,7 +35,6 @@ describe('send(file).pipe(res)', function () { it('should stream a zero-length file', function (done) { request(app) .get('/empty.txt') - .expect('Content-Length', '0') .expect(200, '', done) })