RPC tooBusy response has 503 HTTP status if "ripplerpc": "3.0": (#4143)

Fixes #4005

Makes it possible for internal RPC Error Codes to associate
themselves with a non-OK (200) HTTP status code.  There are
quite a number of RPC responses in addition to tooBusy that
now have non-OK HTTP status codes.

The new return HTTP return codes are only enabled by including
"ripplerpc": "3.0" or higher in the original request.
Otherwise the historical value, 200, continues to be returned.
This ensures that this is not a breaking change.
This commit is contained in:
Scott Schurr
2023-01-03 07:24:45 -10:00
committed by Denis Angell
parent 5f12c22fbe
commit c50eb7773f
6 changed files with 154 additions and 108 deletions

View File

@@ -61,7 +61,7 @@ HTTPReply(
{
JLOG(j.trace()) << "HTTP Reply " << nStatus << " " << content;
if (nStatus == 401)
if (content.empty() && nStatus == 401)
{
output("HTTP/1.0 401 Authorization Required\r\n");
output(getHTTPHeaderTimestamp());
@@ -100,18 +100,33 @@ HTTPReply(
case 200:
output("HTTP/1.1 200 OK\r\n");
break;
case 202:
output("HTTP/1.1 202 Accepted\r\n");
break;
case 400:
output("HTTP/1.1 400 Bad Request\r\n");
break;
case 401:
output("HTTP/1.1 401 Authorization Required\r\n");
break;
case 403:
output("HTTP/1.1 403 Forbidden\r\n");
break;
case 404:
output("HTTP/1.1 404 Not Found\r\n");
break;
case 405:
output("HTTP/1.1 405 Method Not Allowed\r\n");
break;
case 429:
output("HTTP/1.1 429 Too Many Requests\r\n");
break;
case 500:
output("HTTP/1.1 500 Internal Server Error\r\n");
break;
case 501:
output("HTTP/1.1 501 Not Implemented\r\n");
break;
case 503:
output("HTTP/1.1 503 Server is overloaded\r\n");
break;