Skip to content

Commit ac5c5d0

Browse files
committed
Merge #18168: httpserver: use own HTTP status codes
aff2748 httpserver: use own HTTP status codes (Filip Gospodinov) Pull request description: Before, macros defined in `<event2/http.h>` have been used for some HTTP status codes. `<event2/http.h>` is included implicitly and the usage of its status code macros is inconsistent with the majority HTTP response implementations in this file. Now, the `HTTPStatusCode` enum from `<rpc/protocol.h>` is consistently used for all HTTP response implementations. ACKs for top commit: practicalswift: ACK aff2748 -- patch looks correct laanwj: ACK aff2748 Tree-SHA512: 6a7043488b88dcd584215d16b5f16f7bd668fe5553d31298d1beef134d2b0648aef81533014e34d1cd600baa36ee4e853f195352f4a00c866bd5ab1ff688bd50
2 parents 1f88624 + aff2748 commit ac5c5d0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/httpserver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
236236
if (hreq->GetRequestMethod() == HTTPRequest::UNKNOWN) {
237237
LogPrint(BCLog::HTTP, "HTTP request from %s rejected: Unknown HTTP request method\n",
238238
hreq->GetPeer().ToString());
239-
hreq->WriteReply(HTTP_BADMETHOD);
239+
hreq->WriteReply(HTTP_BAD_METHOD);
240240
return;
241241
}
242242

@@ -268,10 +268,10 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
268268
item.release(); /* if true, queue took ownership */
269269
else {
270270
LogPrintf("WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting\n");
271-
item->req->WriteReply(HTTP_INTERNAL, "Work queue depth exceeded");
271+
item->req->WriteReply(HTTP_INTERNAL_SERVER_ERROR, "Work queue depth exceeded");
272272
}
273273
} else {
274-
hreq->WriteReply(HTTP_NOTFOUND);
274+
hreq->WriteReply(HTTP_NOT_FOUND);
275275
}
276276
}
277277

@@ -519,7 +519,7 @@ HTTPRequest::~HTTPRequest()
519519
if (!replySent) {
520520
// Keep track of whether reply was sent to avoid request leaks
521521
LogPrintf("%s: Unhandled request\n", __func__);
522-
WriteReply(HTTP_INTERNAL, "Unhandled request");
522+
WriteReply(HTTP_INTERNAL_SERVER_ERROR, "Unhandled request");
523523
}
524524
// evhttpd cleans up the request, as long as a reply was sent.
525525
}

0 commit comments

Comments
 (0)