![]() |
Bitcoin Core 31.99.0
P2P Digital Currency
|
#include <atomic>#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>Go to the source code of this file.
Classes | |
| struct | bitcoin_http::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 | HTTPHeaders |
| struct | HTTPVersion |
| struct | HTTPResponse |
| class | HTTPRequest |
| class | HTTPServer |
| struct | HTTPServer::IOReadiness |
| Info about which socket has which event ready and a reverse map back to the HTTPRemoteClient that owns the socket. More... | |
| class | HTTPRemoteClient |
Namespaces | |
| namespace | util |
| namespace | bitcoin_http |
Typedefs | |
| using | HTTPRequestHandler = std::function< void(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 > | GetQueryParameterFromUri (std::string_view uri, std::string_view key) |
| bool | InitHTTPServer () |
| Initialize HTTP server. More... | |
| void | StartHTTPServer () |
| Start HTTP server. More... | |
| void | InterruptHTTPServer () |
| Interrupt HTTP server threads. More... | |
| void | StopHTTPServer () |
| Stop HTTP server. More... | |
Variables | |
| constexpr int | DEFAULT_HTTP_THREADS =16 |
The default value for -rpcthreads. More... | |
| constexpr int | DEFAULT_HTTP_WORKQUEUE =64 |
The default value for -rpcworkqueue. More... | |
| constexpr int | DEFAULT_HTTP_SERVER_TIMEOUT =30 |
| constexpr int | DEFAULT_MAX_HTTP_CONNECTIONS = 16 |
| Maximum number of connected HTTP clients. More... | |
| constexpr size_t | bitcoin_http::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 | bitcoin_http::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 | bitcoin_http::MAX_BODY_SIZE {32_MiB} |
| Maximum size of an HTTP request body. More... | |
| using HTTPRequestHandler = std::function<void(HTTPRequest* req, const std::string&)> |
Handler for requests to a certain HTTP path.
Definition at line 60 of file httpserver.h.
|
strong |
| Enumerator | |
|---|---|
| UNKNOWN | |
| GET | |
| POST | |
| HEAD | |
| PUT | |
Definition at line 49 of file httpserver.h.
| std::optional< std::string > GetQueryParameterFromUri | ( | std::string_view | uri, |
| std::string_view | key | ||
| ) |
Definition at line 673 of file httpserver.cpp.
| bool InitHTTPServer | ( | ) |
Initialize HTTP server.
Call this before RegisterHTTPHandler or EventBase().
Definition at line 1298 of file httpserver.cpp.
| void InterruptHTTPServer | ( | ) |
Interrupt HTTP server threads.
Definition at line 1352 of file httpserver.cpp.
| 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.
| void 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 1344 of file httpserver.cpp.
| void StopHTTPServer | ( | ) |
Stop HTTP server.
Definition at line 1364 of file httpserver.cpp.
| void UnregisterHTTPHandler | ( | const std::string & | prefix, |
| bool | exactMatch | ||
| ) |
Unregister handler for prefix.
Definition at line 248 of file httpserver.cpp.
|
inlineconstexpr |
Definition at line 42 of file httpserver.h.
|
inlineconstexpr |
The default value for -rpcthreads.
This number of threads will be created at startup.
Definition at line 34 of file httpserver.h.
|
inlineconstexpr |
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 40 of file httpserver.h.
|
inlineconstexpr |
Maximum number of connected HTTP clients.
Definition at line 47 of file httpserver.h.