Skip to content

Commit b5a80fa

Browse files
hebastoLarryRuane
authored andcommitted
util: Handle HTTP_SERVICE_UNAVAILABLE in bitcoin-cli
1 parent 4db44ac commit b5a80fa

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/bitcoin-cli.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
429429
} else {
430430
throw std::runtime_error("Authorization failed: Incorrect rpcuser or rpcpassword");
431431
}
432+
} else if (response.status == HTTP_SERVICE_UNAVAILABLE) {
433+
throw std::runtime_error(strprintf("Server response: %s", response.body));
432434
} else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR)
433435
throw std::runtime_error(strprintf("server returned HTTP error %d", response.status));
434436
else if (response.body.empty())

src/httpserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
269269
item.release(); /* if true, queue took ownership */
270270
else {
271271
LogPrintf("WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting\n");
272-
item->req->WriteReply(HTTP_INTERNAL_SERVER_ERROR, "Work queue depth exceeded");
272+
item->req->WriteReply(HTTP_SERVICE_UNAVAILABLE, "Work queue depth exceeded");
273273
}
274274
} else {
275275
hreq->WriteReply(HTTP_NOT_FOUND);

0 commit comments

Comments
 (0)