Skip to content
Myr

Started naive Range support

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 903f67a · Browse files · 2 files+23 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−5 removed

  • other:+23 added−5 removed

2 files+23 added−5 removed

modified:lib/express/response.js+18 added-3 removed
150 unmodified lines
151152 fs.stat(path, function(err, stat){153 if (err) return error(err);154 if (stat.size >= streamThreshold) {155 var status = 200;156 if (ranges) {157 var stream = fs.createReadStream(path, ranges[0]),158 start = ranges[0].start,159 end = ranges[0].end;160 status = 206;161 self.header('Content-Range', 'bytes '162 + start163 + '-'164 + end165 + '/'166 + stat.size);167 self.header('Content-Length', end - start + 1);168 } else {155 var stream = fs.createReadStream(path);169 var stream = fs.createReadStream(path);170 self.header('Content-Length', stat.size);171 }172 self.contentType(path);173 self.header('Accept-Ranges', 'bytes');158 self.header('Content-Length', stat.size);159 self.writeHead(200, self.headers);174 self.writeHead(status, self.headers);175 pump(stream, self, function(err){176 fn && fn(err, path, true);177 });178 } else {
183 unmodified lines
modified:lib/express/utils.js+5 added-2 removed