rpc: Make HTTP RPC debug logging more informative

This commit is contained in:
practicalswift 2018-10-31 11:42:01 +01:00
parent 76ae7a1ac9
commit 991248649b

View file

@ -224,21 +224,25 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
} }
std::unique_ptr<HTTPRequest> hreq(new HTTPRequest(req)); std::unique_ptr<HTTPRequest> hreq(new HTTPRequest(req));
LogPrint(BCLog::HTTP, "Received a %s request for %s from %s\n",
RequestMethodString(hreq->GetRequestMethod()), hreq->GetURI(), hreq->GetPeer().ToString());
// Early address-based allow check // Early address-based allow check
if (!ClientAllowed(hreq->GetPeer())) { if (!ClientAllowed(hreq->GetPeer())) {
LogPrint(BCLog::HTTP, "HTTP request from %s rejected: Client network is not allowed RPC access\n",
hreq->GetPeer().ToString());
hreq->WriteReply(HTTP_FORBIDDEN); hreq->WriteReply(HTTP_FORBIDDEN);
return; return;
} }
// Early reject unknown HTTP methods // Early reject unknown HTTP methods
if (hreq->GetRequestMethod() == HTTPRequest::UNKNOWN) { if (hreq->GetRequestMethod() == HTTPRequest::UNKNOWN) {
LogPrint(BCLog::HTTP, "HTTP request from %s rejected: Unknown HTTP request method\n",
hreq->GetPeer().ToString());
hreq->WriteReply(HTTP_BADMETHOD); hreq->WriteReply(HTTP_BADMETHOD);
return; return;
} }
LogPrint(BCLog::HTTP, "Received a %s request for %s from %s\n",
RequestMethodString(hreq->GetRequestMethod()), SanitizeString(hreq->GetURI()).substr(0, 100), hreq->GetPeer().ToString());
// Find registered handler for prefix // Find registered handler for prefix
std::string strURI = hreq->GetURI(); std::string strURI = hreq->GetURI();
std::string path; std::string path;