PIVX Core  5.6.99
P2P Digital Currency
Classes | Macros | Functions | Variables
httpserver.cpp File Reference
#include "httpserver.h"
#include "chainparamsbase.h"
#include "compat.h"
#include "util/system.h"
#include "netbase.h"
#include "rpc/protocol.h"
#include "sync.h"
#include "shutdown.h"
#include "guiinterface.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <deque>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <event2/thread.h>
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include <event2/util.h>
#include <event2/keyvalq_struct.h>
#include "support/events.h"
Include dependency graph for httpserver.cpp:

Go to the source code of this file.

Classes

class  HTTPWorkItem
 HTTP request work item. More...
 
class  WorkQueue< WorkItem >
 Simple work queue for distributing work over multiple threads. More...
 
struct  HTTPPathHandler
 

Macros

#define EVENT_LOG_WARN   _EVENT_LOG_WARN
 

Functions

bool InitHTTPServer ()
 Initialize HTTP server. More...
 
bool UpdateHTTPServerLogging (bool enable)
 Change logging level for libevent. More...
 
bool StartHTTPServer ()
 Start HTTP server. More...
 
void InterruptHTTPServer ()
 Interrupt HTTP server threads. More...
 
void StopHTTPServer ()
 Stop HTTP server. More...
 
struct event_base * EventBase ()
 Return evhttp event base. 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...
 
std::string urlDecode (const std::string &urlEncoded)
 

Variables

struct evhttp * eventHTTP = 0
 HTTP server. More...
 
std::vector< HTTPPathHandlerpathHandlers
 Handlers for (sub)paths. More...
 
std::vector< evhttp_bound_socket * > boundSockets
 
std::thread threadHTTP
 

Macro Definition Documentation

◆ EVENT_LOG_WARN

#define EVENT_LOG_WARN   _EVENT_LOG_WARN

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 501 of file httpserver.cpp.

◆ InitHTTPServer()

bool InitHTTPServer ( )

Initialize HTTP server.

Call this before RegisterHTTPHandler or EventBase().

Definition at line 356 of file httpserver.cpp.

Here is the caller graph for this function:

◆ InterruptHTTPServer()

void InterruptHTTPServer ( )

Interrupt HTTP server threads.

Definition at line 444 of file httpserver.cpp.

Here is the caller graph for this function:

◆ 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 659 of file httpserver.cpp.

◆ 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 431 of file httpserver.cpp.

Here is the call graph for this function:

◆ StopHTTPServer()

void StopHTTPServer ( )

Stop HTTP server.

Definition at line 455 of file httpserver.cpp.

◆ UnregisterHTTPHandler()

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

Unregister handler for prefix.

Definition at line 665 of file httpserver.cpp.

Here is the caller graph for this function:

◆ UpdateHTTPServerLogging()

bool UpdateHTTPServerLogging ( bool  enable)

Change logging level for libevent.

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

Definition at line 414 of file httpserver.cpp.

Here is the caller graph for this function:

◆ urlDecode()

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

Definition at line 679 of file httpserver.cpp.

Variable Documentation

◆ boundSockets

std::vector<evhttp_bound_socket *> boundSockets

Definition at line 155 of file httpserver.cpp.

◆ eventHTTP

struct evhttp* eventHTTP = 0

HTTP server.

Definition at line 148 of file httpserver.cpp.

◆ pathHandlers

std::vector<HTTPPathHandler> pathHandlers

Handlers for (sub)paths.

Definition at line 154 of file httpserver.cpp.

◆ threadHTTP

std::thread threadHTTP

Definition at line 428 of file httpserver.cpp.