+404
This commit is contained in:
parent
e26930bdbf
commit
8d6ac4afcc
|
@ -181,7 +181,8 @@ function Websrv(tlib) {
|
|||
var start = 0;
|
||||
var end = 0;
|
||||
var range = req.headers['range'];
|
||||
var stat = fs.statSync(filePath);
|
||||
fs.stat(filePath, (err, stat) => {
|
||||
if(!err) {
|
||||
if(range != null) {
|
||||
start = parseInt(range.slice(range.indexOf('bytes=')+6, range.indexOf('-')));
|
||||
end = parseInt(range.slice(range.indexOf('-')+1, range.length));
|
||||
|
@ -198,6 +199,12 @@ function Websrv(tlib) {
|
|||
var stream = fs.createReadStream(filePath, { flags: 'r', start: start, end: end});
|
||||
stream.pipe(res);
|
||||
}
|
||||
else {
|
||||
res.writeHead(200, { 'Content-Type': contentType });
|
||||
res.end('404 - f0ck you', 'utf-8');
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
fs.readFile(filePath, (error, content) => {
|
||||
if(error) {
|
||||
|
@ -218,20 +225,6 @@ function Websrv(tlib) {
|
|||
});
|
||||
}
|
||||
}
|
||||
/*fs.readFile(filePath, (error, content) => {
|
||||
if(error) {
|
||||
if(error.code == 'ENOENT') {
|
||||
res.writeHead(200, { 'Content-Type': contentType });
|
||||
res.end('404 - f0ck you', 'utf-8');
|
||||
}
|
||||
else {
|
||||
res.writeHead(500);
|
||||
res.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
|
||||
res.end();
|
||||
}
|
||||
}
|
||||
});*/
|
||||
//}
|
||||
else if(filePath.match(/^\.\/api/i)) { // api
|
||||
var url = filePath.split('/');
|
||||
if(url[2] === undefined) { // Mainpage
|
||||
|
|
Loading…
Reference in New Issue
Block a user