5 #ifndef BITCOIN_HTTPSERVER_H
6 #define BITCOIN_HTTPSERVER_H
12 static const int DEFAULT_HTTP_THREADS=4;
13 static const int DEFAULT_HTTP_WORKQUEUE=16;
14 static const int DEFAULT_HTTP_SERVER_TIMEOUT=30;
16 struct evhttp_request;
56 struct evhttp_request*
req;
87 std::pair<bool, std::string>
GetHeader(
const std::string& hdr);
102 void WriteHeader(
const std::string& hdr,
const std::string& value);
112 void WriteReply(
int nStatus,
const std::string& strReply =
"");
139 void trigger(
struct timeval* tv);
A combination of a network address (CNetAddr) and a (TCP) port.
virtual void operator()()=0
std::function< void(void)> handler
HTTPEvent(struct event_base *base, bool deleteWhenTriggered, const std::function< void(void)> &handler)
Create a new event.
void trigger(struct timeval *tv)
Trigger the event.
void WriteReply(int nStatus, const std::string &strReply="")
Write HTTP reply.
std::string GetURI()
Get requested URI.
CService GetPeer()
Get CService (address:ip) for the origin of the http request.
std::pair< bool, std::string > GetHeader(const std::string &hdr)
Get the request header specified by hdr, or an empty string.
void WriteHeader(const std::string &hdr, const std::string &value)
Write output header.
struct evhttp_request * req
HTTPRequest(struct evhttp_request *req)
std::string ReadBody()
Read request body.
RequestMethod GetRequestMethod()
Get request method.
void InterruptHTTPServer()
Interrupt HTTP server threads.
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.
struct event_base * EventBase()
Return evhttp event base.
bool InitHTTPServer()
Initialize HTTP server.
bool StartHTTPServer()
Start HTTP server.
std::function< bool(HTTPRequest *req, const std::string &)> HTTPRequestHandler
Handler for requests to a certain HTTP path.
void StopHTTPServer()
Stop HTTP server.
bool(* handler)(HTTPRequest *req, const std::string &strReq)