Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

httpserver.h File Reference
#include <string>
#include <stdint.h>
#include <functional>
+ Include dependency graph for httpserver.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  HTTPRequest
 In-flight HTTP request. More...
 
class  HTTPClosure
 Event handler closure. More...
 
class  HTTPEvent
 Event class. More...
 

Typedefs

typedef std::function< bool(HTTPRequest *req, const std::string &)> HTTPRequestHandler
 Handler for requests to a certain HTTP path. More...
 

Functions

bool InitHTTPServer ()
 Initialize HTTP server. More...
 
bool StartHTTPServer ()
 Start HTTP server. More...
 
void InterruptHTTPServer ()
 Interrupt HTTP server threads. More...
 
void StopHTTPServer ()
 Stop HTTP server. More...
 
bool UpdateHTTPServerLogging (bool enable)
 Change logging level for libevent. More...
 
void RegisterHTTPHandler (const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler)
 Register handler for prefix. More...
 
void UnregisterHTTPHandler (const std::string &prefix, bool exactMatch)
 Unregister handler for prefix. More...
 
struct event_base * EventBase ()
 Return evhttp event base. More...
 
std::string urlDecode (const std::string &urlEncoded)
 

Variables

static const int DEFAULT_HTTP_THREADS =4
 
static const int DEFAULT_HTTP_WORKQUEUE =16
 
static const int DEFAULT_HTTP_SERVER_TIMEOUT =30
 

Typedef Documentation

◆ HTTPRequestHandler

typedef std::function<bool(HTTPRequest* req, const std::string &)> HTTPRequestHandler

Handler for requests to a certain HTTP path.

Definition at line 40 of file httpserver.h.

Function Documentation

◆ EventBase()

struct event_base* EventBase ( )

Return evhttp event base.

This can be used by submodules to queue timers or custom events.

Definition at line 487 of file httpserver.cpp.

References eventBase.

Referenced by StartHTTPRPC().

◆ InitHTTPServer()

◆ InterruptHTTPServer()

void InterruptHTTPServer ( )

Interrupt HTTP server threads.

Definition at line 443 of file httpserver.cpp.

References eventHTTP, BCLog::HTTP, http_reject_request_cb(), LogPrint, and workQueue.

Referenced by Interrupt().

◆ RegisterHTTPHandler()

void RegisterHTTPHandler ( const std::string &  prefix,
bool  exactMatch,
const HTTPRequestHandler handler 
)

Register handler for prefix.

If multiple handlers match a prefix, the first-registered one will be invoked.

Definition at line 645 of file httpserver.cpp.

References handler, BCLog::HTTP, LogPrint, pathHandlers, and prefix.

Referenced by StartHTTPRPC(), and StartREST().

◆ StartHTTPServer()

bool StartHTTPServer ( )

Start HTTP server.

This is separate from InitHTTPServer to give users race-condition-free time to register their handlers between InitHTTPServer and StartHTTPServer.

Definition at line 430 of file httpserver.cpp.

References DEFAULT_HTTP_THREADS, eventBase, eventHTTP, g_thread_http_workers, gArgs, ArgsManager::GetArg(), BCLog::HTTP, HTTPWorkQueueRun(), L, LogPrint, LogPrintf, ThreadHTTP(), threadHTTP, and workQueue.

Referenced by AppInitServers().

◆ StopHTTPServer()

void StopHTTPServer ( )

Stop HTTP server.

Definition at line 454 of file httpserver.cpp.

References boundSockets, eventBase, eventHTTP, g_thread_http_workers, BCLog::HTTP, LogPrint, threadHTTP, and workQueue.

Referenced by PrepareShutdown().

◆ UnregisterHTTPHandler()

void UnregisterHTTPHandler ( const std::string &  prefix,
bool  exactMatch 
)

Unregister handler for prefix.

Definition at line 651 of file httpserver.cpp.

References BCLog::HTTP, LogPrint, pathHandlers, and prefix.

Referenced by StopHTTPRPC(), and StopREST().

◆ UpdateHTTPServerLogging()

bool UpdateHTTPServerLogging ( bool  enable)

Change logging level for libevent.

Removes BCLog::LIBEVENT from logCategories if libevent doesn't support debug logging.

Definition at line 413 of file httpserver.cpp.

Referenced by InitHTTPServer(), and logging().

◆ urlDecode()

std::string urlDecode ( const std::string &  urlEncoded)

Definition at line 665 of file httpserver.cpp.

Referenced by GetWalletForJSONRPCRequest().

Variable Documentation

◆ DEFAULT_HTTP_SERVER_TIMEOUT

const int DEFAULT_HTTP_SERVER_TIMEOUT =30
static

Definition at line 14 of file httpserver.h.

Referenced by HelpMessage(), and InitHTTPServer().

◆ DEFAULT_HTTP_THREADS

const int DEFAULT_HTTP_THREADS =4
static

Definition at line 12 of file httpserver.h.

Referenced by HelpMessage(), and StartHTTPServer().

◆ DEFAULT_HTTP_WORKQUEUE

const int DEFAULT_HTTP_WORKQUEUE =16
static

Definition at line 13 of file httpserver.h.

Referenced by HelpMessage(), and InitHTTPServer().

Released under the MIT license