Bitcoin Core 31.99.0
P2P Digital Currency
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
httpserver.h File Reference
#include <atomic>
#include <deque>
#include <functional>
#include <memory>
#include <optional>
#include <span>
#include <stdexcept>
#include <string>
#include <vector>
#include <netaddress.h>
#include <rpc/protocol.h>
#include <util/byte_units.h>
#include <util/expected.h>
#include <util/sock.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/threadinterrupt.h>
#include <util/time.h>
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

struct  http_bitcoin::ContentTooLargeError
 Thrown when a request body exceeds MAX_BODY_SIZE (or will exceed, in chunked transfer) so the server can reply with more specific code 413 (content too large) vs general 400 (bad request) More...
 
class  http_bitcoin::HTTPHeaders
 
struct  http_bitcoin::HTTPVersion
 
class  http_bitcoin::HTTPResponse
 
class  http_bitcoin::HTTPRequest
 
class  http_bitcoin::HTTPServer
 
struct  http_bitcoin::HTTPServer::IOReadiness
 Info about which socket has which event ready and a reverse map back to the HTTPRemoteClient that owns the socket. More...
 
class  http_bitcoin::HTTPRemoteClient
 

Namespaces

namespace  util
 
namespace  http_bitcoin
 

Typedefs

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

Enumerations

enum class  HTTPRequestMethod {
  UNKNOWN , GET , POST , HEAD ,
  PUT
}
 

Functions

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::optional< std::string > http_bitcoin::GetQueryParameterFromUri (const std::string_view uri, const std::string_view key)
 
bool http_bitcoin::InitHTTPServer ()
 Initialize HTTP server. More...
 
void http_bitcoin::StartHTTPServer ()
 Start HTTP server. More...
 
void http_bitcoin::InterruptHTTPServer ()
 Interrupt HTTP server threads. More...
 
void http_bitcoin::StopHTTPServer ()
 Stop HTTP server. More...
 

Variables

static const int DEFAULT_HTTP_THREADS =16
 The default value for -rpcthreads. More...
 
static const int DEFAULT_HTTP_WORKQUEUE =64
 The default value for -rpcworkqueue. More...
 
static const int DEFAULT_HTTP_SERVER_TIMEOUT =30
 
constexpr size_t http_bitcoin::MIN_REQUEST_LINE_LENGTH = std::string_view("GET / HTTP/1.0").size()
 Shortest valid request line, used by libevent in evhttp_parse_request_line() More...
 
constexpr size_t http_bitcoin::MAX_HEADERS_SIZE {8192}
 Maximum size of each headers line in an HTTP request, also the maximum size of all headers total. More...
 
constexpr uint64_t http_bitcoin::MAX_BODY_SIZE {32_MiB}
 Maximum size of an HTTP request body. More...
 

Typedef Documentation

◆ HTTPRequestHandler

using HTTPRequestHandler = std::function<void(http_bitcoin::HTTPRequest* req, const std::string&)>

Handler for requests to a certain HTTP path.

Definition at line 57 of file httpserver.h.

Enumeration Type Documentation

◆ HTTPRequestMethod

enum class HTTPRequestMethod
strong
Enumerator
UNKNOWN 
GET 
POST 
HEAD 
PUT 

Definition at line 45 of file httpserver.h.

Function Documentation

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

Here is the caller graph for this function:

◆ UnregisterHTTPHandler()

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

Unregister handler for prefix.

Definition at line 248 of file httpserver.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ DEFAULT_HTTP_SERVER_TIMEOUT

const int DEFAULT_HTTP_SERVER_TIMEOUT =30
static

Definition at line 43 of file httpserver.h.

◆ DEFAULT_HTTP_THREADS

const int DEFAULT_HTTP_THREADS =16
static

The default value for -rpcthreads.

This number of threads will be created at startup.

Definition at line 35 of file httpserver.h.

◆ DEFAULT_HTTP_WORKQUEUE

const int DEFAULT_HTTP_WORKQUEUE =64
static

The default value for -rpcworkqueue.

This is the maximum depth of the work queue, we don't allocate this number of work queue items upfront.

Definition at line 41 of file httpserver.h.