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;
60 struct evhttp_request*
req;
77 std::string
GetURI()
const;
91 std::pair<bool, std::string>
GetHeader(
const std::string& hdr)
const;
106 void WriteHeader(
const std::string& hdr,
const std::string& value);
116 void WriteReply(
int nStatus,
const std::string& strReply =
"");
143 void trigger(
struct timeval* tv);
151 std::string
urlDecode(
const std::string &urlEncoded);
153 #endif // BITCOIN_HTTPSERVER_H bool(* handler)(HTTPRequest *req, const std::string &strReq)
HTTPRequest(struct evhttp_request *req)
bool InitHTTPServer()
Initialize HTTP server.
struct evhttp_request * req
void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch)
Unregister handler for prefix.
void InterruptHTTPServer()
Interrupt HTTP server threads.
void StartHTTPServer()
Start HTTP server.
void WriteReply(int nStatus, const std::string &strReply="")
Write HTTP reply.
struct event_base * EventBase()
Return evhttp event base.
HTTPEvent(struct event_base *base, bool deleteWhenTriggered, const std::function< void()> &handler)
Create a new event.
RequestMethod GetRequestMethod() const
Get request method.
A combination of a network address (CNetAddr) and a (TCP) port.
virtual void operator()()=0
void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler)
Register handler for prefix.
void WriteHeader(const std::string &hdr, const std::string &value)
Write output header.
bool UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
void trigger(struct timeval *tv)
Trigger the event.
std::string urlDecode(const std::string &urlEncoded)
std::pair< bool, std::string > GetHeader(const std::string &hdr) const
Get the request header specified by hdr, or an empty string.
std::function< void()> handler
std::function< bool(HTTPRequest *req, const std::string &)> HTTPRequestHandler
Handler for requests to a certain HTTP path.
CService GetPeer() const
Get CService (address:ip) for the origin of the http request.
std::string ReadBody()
Read request body.
void StopHTTPServer()
Stop HTTP server.
std::string GetURI() const
Get requested URI.