Skip to content

Commit

Permalink
Taper off on notices (#1572)
Browse files Browse the repository at this point in the history
* Useful for those ignoring
* Update responses to match status code elsewhere. This is handled differently in some browsers.

Applies to #1548 #944 and post #1559 #1569

Auto-merge
  • Loading branch information
Martii committed Jan 15, 2019
1 parent 81de21b commit fe03d91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ exports.sendScript = function (aReq, aRes, aNext) {
} catch (aE) {
aRes.set('Warning', '199 ' + aReq.headers.host +
rfc2047.encode(' Invalid @updateURL'));
aRes.status(444).send(); // No Response
aRes.status(400).send(); // Bad request
return;
}

Expand Down Expand Up @@ -613,7 +613,7 @@ exports.sendScript = function (aReq, aRes, aNext) {
if (hasAlternateLocalUpdateURL) {
aRes.set('Warning', '199 ' + aReq.headers.host +
rfc2047.encode(' Invalid @updateURL in lockdown'));
aRes.status(444).send(); // No Response
aRes.status(404).send(); // Not found
return;
}
}
Expand Down
30 changes: 20 additions & 10 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,26 @@ var listLimiter = rateLimit({
windowMs: listMin * 60 * 1000, // n minutes for all stores
max: 100, // limit each IP to n requests per windowMs for memory store or expireTimeMs for mongo store
handler: function (aReq, aRes, aNext) {
aRes.header('Retry-After', listMin * 60 + 60);
statusCodePage(aReq, aRes, aNext, {
statusCode: 429,
statusMessage: 'Too many requests.',
isCustomView: true,
statusData: {
isListView: true,
retryAfter: listMin * 60 + 60
}
});
if (aReq.rateLimit.current < aReq.rateLimit.limit + 5) {
aRes.header('Retry-After', listMin * 60 + 60);
statusCodePage(aReq, aRes, aNext, {
statusCode: 429,
statusMessage: 'Too many requests.',
isCustomView: true,
statusData: {
isListView: true,
retryAfter: listMin * 60 + 60
}
});
} else if (aReq.rateLimit.current < aReq.rateLimit.limit + 10) {
aRes.header('Retry-After', listMin * 60 + 60);
aRes.status(429).send('Too many requests. Please try again later');
} else if (aReq.rateLimit.current < aReq.rateLimit.limit + 15) {
aRes.header('Retry-After', listMin * 60 + 60);
aRes.status(429).send();
} else {
aRes.connection.destroy();
}
}
});

Expand Down

0 comments on commit fe03d91

Please sign in to comment.