6#ifndef BITCOIN_HTTPSERVER_H
7#define BITCOIN_HTTPSERVER_H
86 std::string
GetURI()
const;
98 std::pair<bool, std::string>
GetHeader(
const std::string &hdr)
const;
113 void WriteHeader(
const std::string &hdr,
const std::string &value);
148 const std::function<
void()> &
handler);
A combination of a network address (CNetAddr) and a (TCP) port.
virtual void operator()()=0
std::function< void()> handler
void trigger(struct timeval *tv)
Trigger the event.
std::pair< bool, std::string > GetHeader(const std::string &hdr) const
Get the request header specified by hdr, or an empty string.
std::string GetURI() const
Get requested URI.
void WriteReply(int nStatus, const std::string &strReply="")
Write HTTP reply.
void WriteHeader(const std::string &hdr, const std::string &value)
Write output header.
struct evhttp_request * req
RequestMethod GetRequestMethod() const
Get request method.
std::string ReadBody()
Read request body.
CService GetPeer() const
Get CService (address:ip) for the origin of the http request.
void InterruptHTTPServer()
Interrupt HTTP server threads.
static const int DEFAULT_HTTP_SERVER_TIMEOUT
void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch)
Unregister handler for prefix.
void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler)
Register handler for prefix.
static const int DEFAULT_HTTP_WORKQUEUE
void StartHTTPServer()
Start HTTP server.
struct event_base * EventBase()
Return evhttp event base.
bool UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
static const int DEFAULT_HTTP_THREADS
std::function< bool(Config &config, HTTPRequest *req, const std::string &)> HTTPRequestHandler
Handler for requests to a certain HTTP path.
void StopHTTPServer()
Stop HTTP server.
bool InitHTTPServer(Config &config)
Initialize HTTP server.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
bool(* handler)(Config &config, const std::any &context, HTTPRequest *req, const std::string &strReq)