![]() |
Bitcoin Core 32.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. | |
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. | |
| void | UnregisterHTTPHandler (const std::string &prefix, bool exactMatch) |
| Unregister handler for prefix. | |
| std::optional< std::string > | GetQueryParameterFromUri (std::string_view uri, std::string_view key) |
| bool | InitHTTPServer () |
| Initialize HTTP server. | |
| void | StartHTTPServer () |
| Start HTTP server. | |
| void | InterruptHTTPServer () |
| Interrupt HTTP server threads. | |
| void | StopHTTPServer () |
| Stop HTTP server. | |
Variables | |
| constexpr int | DEFAULT_HTTP_THREADS =16 |
The default value for -rpcthreads. | |
| constexpr int | DEFAULT_HTTP_WORKQUEUE =64 |
The default value for -rpcworkqueue. | |
| constexpr int | DEFAULT_HTTP_SERVER_TIMEOUT =30 |
| constexpr int | DEFAULT_MAX_HTTP_CONNECTIONS = 16 |
| Maximum number of connected HTTP clients. | |
| 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() | |
| 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. | |
| constexpr uint64_t | bitcoin_http::MAX_BODY_SIZE {32_MiB} |
| Maximum size of an HTTP request body received from a client. | |
| 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 672 of file httpserver.cpp.
| bool InitHTTPServer | ( | ) |
Initialize HTTP server.
Call this before RegisterHTTPHandler or EventBase().
Definition at line 1352 of file httpserver.cpp.
| void InterruptHTTPServer | ( | ) |
Interrupt HTTP server threads.
Definition at line 1406 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 1398 of file httpserver.cpp.
| void StopHTTPServer | ( | ) |
Stop HTTP server.
Definition at line 1418 of file httpserver.cpp.
Unregister handler for prefix.
Definition at line 248 of file httpserver.cpp.
Definition at line 42 of file httpserver.h.
The default value for -rpcthreads.
This number of threads will be created at startup.
Definition at line 34 of file httpserver.h.
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.
Maximum number of connected HTTP clients.
Definition at line 47 of file httpserver.h.