muh
This commit is contained in:
parent
c7bdf67436
commit
b257e53a60
|
@ -69,7 +69,7 @@ function Websrv(tlib) {
|
|||
'.jpg': 'image/jpg',
|
||||
'.gif': 'image/gif',
|
||||
'.mp3': 'audio/mpeg',
|
||||
'.flac': 'audio/x-flac',
|
||||
'.flac': 'audio/x-flac',
|
||||
'.mp4': 'video/mp4',
|
||||
'.webm': 'video/webm',
|
||||
'.ogg': 'audio/ogg',
|
||||
|
@ -182,33 +182,32 @@ function Websrv(tlib) {
|
|||
|| contentType === "video/mp4"
|
||||
|| contentType === "video/quicktime"
|
||||
|| contentType === "audio/mpeg"
|
||||
|| contentType === "audio/flac"
|
||||
|| contentType === "audio/x-flac"
|
||||
|| contentType === "audio/flac"
|
||||
|| contentType === "audio/x-flac"
|
||||
|| contentType === "audio/ogg") && req.headers['range']) {
|
||||
fs.readFile(filePath, "binary", function(err, file) {
|
||||
if(typeof req.headers.range !== 'undefined') {
|
||||
var range = req.headers.range;
|
||||
var parts = range.replace(/bytes=/, "").split("-");
|
||||
var partialstart = parts[0];
|
||||
var partialend = parts[1];
|
||||
var total = file.length;
|
||||
var start = parseInt(partialstart, 10);
|
||||
var end = partialend ? parseInt(partialend, 10) : total-1;
|
||||
|
||||
res.writeHead(206, {
|
||||
"Content-Range": "bytes " + start + "-" + end + "/" + (total),
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Length": (end-start)+1,
|
||||
"Transfer-Encoding": "chunked",
|
||||
"Connection": "close"
|
||||
});
|
||||
res.write(file.slice(start, end)+'0', "binary");
|
||||
}
|
||||
else {
|
||||
res.writeHead(200);
|
||||
res.write(file, "binary");
|
||||
}
|
||||
res.end();
|
||||
if(typeof req.headers.range !== 'undefined') {
|
||||
var range = req.headers.range;
|
||||
var parts = range.replace(/bytes=/, "").split("-");
|
||||
var partialstart = parts[0];
|
||||
var partialend = parts[1];
|
||||
var total = file.length;
|
||||
var start = parseInt(partialstart, 10);
|
||||
var end = partialend ? parseInt(partialend, 10) : total-1;
|
||||
res.writeHead(206, {
|
||||
"Content-Range": "bytes " + start + "-" + end + "/" + (total),
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Length": (end-start)+1,
|
||||
"Transfer-Encoding": "chunked",
|
||||
"Connection": "close"
|
||||
});
|
||||
res.write(file.slice(start, end)+'0', "binary");
|
||||
}
|
||||
else {
|
||||
res.writeHead(200);
|
||||
res.write(file, "binary");
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user