Changeset View
Changeset View
Standalone View
Standalone View
src/httpserver.cpp
Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | static bool InitHTTPAllowList() { | ||||
for (const CSubNet &subnet : rpc_allow_subnets) { | for (const CSubNet &subnet : rpc_allow_subnets) { | ||||
strAllowed += subnet.ToString() + " "; | strAllowed += subnet.ToString() + " "; | ||||
} | } | ||||
LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed); | LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed); | ||||
return true; | return true; | ||||
} | } | ||||
/** HTTP request method as string - use for logging only */ | /** HTTP request method as string - use for logging only */ | ||||
static std::string RequestMethodString(HTTPRequest::RequestMethod m) { | std::string RequestMethodString(HTTPRequest::RequestMethod m) { | ||||
switch (m) { | switch (m) { | ||||
case HTTPRequest::GET: | case HTTPRequest::GET: | ||||
return "GET"; | return "GET"; | ||||
case HTTPRequest::POST: | case HTTPRequest::POST: | ||||
return "POST"; | return "POST"; | ||||
case HTTPRequest::HEAD: | case HTTPRequest::HEAD: | ||||
return "HEAD"; | return "HEAD"; | ||||
case HTTPRequest::PUT: | case HTTPRequest::PUT: | ||||
▲ Show 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | void HTTPEvent::trigger(struct timeval *tv) { | ||||
if (tv == nullptr) { | if (tv == nullptr) { | ||||
// Immediately trigger event in main thread. | // Immediately trigger event in main thread. | ||||
event_active(ev, 0, 0); | event_active(ev, 0, 0); | ||||
} else { | } else { | ||||
// Trigger after timeval passed. | // Trigger after timeval passed. | ||||
evtimer_add(ev, tv); | evtimer_add(ev, tv); | ||||
} | } | ||||
} | } | ||||
HTTPRequest::HTTPRequest(struct evhttp_request *_req) | HTTPRequest::HTTPRequest(struct evhttp_request *_req, bool _replySent) | ||||
: req(_req), replySent(false) {} | : req(_req), replySent(_replySent) {} | ||||
HTTPRequest::~HTTPRequest() { | HTTPRequest::~HTTPRequest() { | ||||
if (!replySent) { | if (!replySent) { | ||||
// Keep track of whether reply was sent to avoid request leaks | // Keep track of whether reply was sent to avoid request leaks | ||||
LogPrintf("%s: Unhandled request\n", __func__); | LogPrintf("%s: Unhandled request\n", __func__); | ||||
WriteReply(HTTP_INTERNAL_SERVER_ERROR, "Unhandled request"); | WriteReply(HTTP_INTERNAL_SERVER_ERROR, "Unhandled request"); | ||||
} | } | ||||
// evhttpd cleans up the request, as long as a reply was sent. | // evhttpd cleans up the request, as long as a reply was sent. | ||||
} | } | ||||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |