Merge pull request #10784 from overleaf/jk-gitbridge-add-rate-limits

[git-bridge] Add rate-limits on GitBridgeRouter

GitOrigin-RevId: ec935fae39cc061cefe3c932304de8cde2fdd185
This commit is contained in:
June Kelly 2022-12-13 11:10:37 +00:00 committed by Copybot
parent bed2596468
commit 7c1e91573c

View file

@ -76,6 +76,13 @@ public abstract class Request<T extends Result> {
int sc = httpCause.getStatusCode();
if (sc == HttpServletResponse.SC_UNAUTHORIZED || sc == HttpServletResponse.SC_FORBIDDEN) { // 401, 403
throw new ForbiddenException();
} else if (sc == 429) { // Too many requests
throw new MissingRepositoryException(Arrays.asList(
"Rate-limit exceeded. Please wait a while and try again.",
"",
"If this is unexpected, please contact us at support@overleaf.com, or",
"see https://www.overleaf.com/help/342 for more information."
));
} else if (sc == HttpServletResponse.SC_CONFLICT) { // 409
try {
JsonObject json = Instance.gson.fromJson(httpCause.getContent(), JsonObject.class);