mirror of https://github.com/calzoneman/sync.git
Don't log HTTP 413, just send it to the client and be done
This commit is contained in:
parent
a3a9fa074e
commit
e8a2753e19
|
@ -0,0 +1,57 @@
|
|||
function fixFilter(f) {
|
||||
if (typeof f.name !== "string" ||
|
||||
typeof f.source !== "string" ||
|
||||
typeof f.replace !== "string") {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
f.replace = f.replace.replace(/([^\\]\\(\d)/g, "$1$$$2");
|
||||
|
||||
if (typeof f.flags !== "string") {
|
||||
f.flags = "";
|
||||
}
|
||||
|
||||
f.active = !!f.active;
|
||||
f.filterlinks = !!f.filterlinks;
|
||||
return f;
|
||||
}
|
||||
|
||||
function NodeFilterList(filters) {
|
||||
if (!filters) filters = [];
|
||||
|
||||
this.filters = filters.map(function (f) {
|
||||
f.regexp = new RegExp(f.source, f.flags);
|
||||
return f;
|
||||
});
|
||||
}
|
||||
|
||||
NodeFilterList.prototype.pack = function () {
|
||||
return this.filters.map(function (f) {
|
||||
return {
|
||||
name: f.name,
|
||||
source: f.source,
|
||||
flags: f.flags,
|
||||
replace: f.replace,
|
||||
active: f.active,
|
||||
filterlinks: f.filterlinks
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
NodeFilterList.prototype.addFilter = function (f) {
|
||||
this.filters.push(f);
|
||||
};
|
||||
|
||||
NodeFilterList.prototype.updateFilter = function (f) {
|
||||
if (!f.name) return;
|
||||
|
||||
for (var i = 0; i < this.filters.length; i++) {
|
||||
if (this.filters[i].name === filter.name) {
|
||||
for (var key in f) {
|
||||
this.filters[i][key] = f[key];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -204,7 +204,10 @@ module.exports = {
|
|||
req._ip = ipForRequest(req);
|
||||
next();
|
||||
});
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: false,
|
||||
limit: '1kb' // No POST data should ever exceed this size under normal usage
|
||||
}));
|
||||
app.use(cookieParser());
|
||||
app.use(morgan(LOG_FORMAT, {
|
||||
stream: require("fs").createWriteStream(path.join(__dirname, "..", "..",
|
||||
|
@ -247,6 +250,8 @@ module.exports = {
|
|||
return res.status(400).send("Malformed path: " + req.path);
|
||||
} else if (err.message && err.message.match(/requested range not/i)) {
|
||||
return res.status(416).end();
|
||||
} else if (err.message && err.message.match(/request entity too large/i)) {
|
||||
return res.status(413).end();
|
||||
} else if (err.message && err.message.match(/bad request/i)) {
|
||||
return res.status(400).end("Bad Request");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue