diff options
Diffstat (limited to 'src/httpserver.h')
| -rw-r--r-- | src/httpserver.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/httpserver.h b/src/httpserver.h index b55b253be..97cd63778 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2016 The Bitcoin Core developers +// Copyright (c) 2015-2020 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -6,7 +6,6 @@ #define BITCOIN_HTTPSERVER_H #include <string> -#include <stdint.h> #include <functional> static const int DEFAULT_HTTP_THREADS=4; @@ -26,12 +25,16 @@ bool InitHTTPServer(); * This is separate from InitHTTPServer to give users race-condition-free time * to register their handlers between InitHTTPServer and StartHTTPServer. */ -bool StartHTTPServer(); +void StartHTTPServer(); /** Interrupt HTTP server threads */ void InterruptHTTPServer(); /** Stop HTTP server */ void StopHTTPServer(); +/** Change logging level for libevent. Removes BCLog::LIBEVENT from log categories if + * libevent doesn't support debug logging.*/ +bool UpdateHTTPServerLogging(bool enable); + /** Handler for requests to a certain HTTP path */ typedef std::function<bool(HTTPRequest* req, const std::string &)> HTTPRequestHandler; /** Register handler for prefix. @@ -57,7 +60,7 @@ private: bool replySent; public: - HTTPRequest(struct evhttp_request* req); + explicit HTTPRequest(struct evhttp_request* req, bool replySent = false); ~HTTPRequest(); enum RequestMethod { @@ -70,21 +73,21 @@ public: /** Get requested URI. */ - std::string GetURI(); + std::string GetURI() const; /** Get CService (address:ip) for the origin of the http request. */ - CService GetPeer(); + CService GetPeer() const; /** Get request method. */ - RequestMethod GetRequestMethod(); + RequestMethod GetRequestMethod() const; /** * Get the request header specified by hdr, or an empty string. - * Return an pair (isPresent,string). + * Return a pair (isPresent,string). */ - std::pair<bool, std::string> GetHeader(const std::string& hdr); + std::pair<bool, std::string> GetHeader(const std::string& hdr) const; /** * Read request body. @@ -121,7 +124,7 @@ public: virtual ~HTTPClosure() {} }; -/** Event class. This can be used either as an cross-thread trigger or as a timer. +/** Event class. This can be used either as a cross-thread trigger or as a timer. */ class HTTPEvent { @@ -130,7 +133,7 @@ public: * deleteWhenTriggered deletes this event object after the event is triggered (and the handler called) * handler is the handler to call when the event is triggered. */ - HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void(void)>& handler); + HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void()>& handler); ~HTTPEvent(); /** Trigger the event. If tv is 0, trigger it immediately. Otherwise trigger it after @@ -139,7 +142,7 @@ public: void trigger(struct timeval* tv); bool deleteWhenTriggered; - std::function<void(void)> handler; + std::function<void()> handler; private: struct event* ev; }; |