![]() |
Bitcoin Core 32.1.0
P2P Digital Currency
|
#include <bitcoin-build-config.h>#include <httpserver.h>#include <chainparamsbase.h>#include <common/args.h>#include <common/messages.h>#include <common/url.h>#include <compat/compat.h>#include <logging.h>#include <netbase.h>#include <node/interface_ui.h>#include <rpc/protocol.h>#include <span.h>#include <sync.h>#include <util/check.h>#include <util/signalinterrupt.h>#include <util/sock.h>#include <util/strencodings.h>#include <util/thread.h>#include <util/threadnames.h>#include <util/threadpool.h>#include <util/time.h>#include <util/translation.h>#include <condition_variable>#include <cstdio>#include <cstdlib>#include <memory>#include <optional>#include <span>#include <string>#include <string_view>#include <thread>#include <unordered_map>#include <vector>#include <sys/types.h>#include <sys/stat.h>Go to the source code of this file.
Classes | |
| struct | HTTPPathHandler |
| class | LineReader |
Functions | |
| static std::vector< HTTPPathHandler > pathHandlers | GUARDED_BY (g_httppathhandlers_mutex) |
| std::string_view | RequestMethodString (HTTPRequestMethod m) |
| HTTP request method as string - use for logging only. | |
| static void | WriteNoStoreErrorReply (HTTPRequest &req, HTTPStatusCode status, std::string_view reply={}) |
| static void | MaybeDispatchRequestToWorker (std::shared_ptr< HTTPRequest > hreq) |
| static void | RejectRequest (std::unique_ptr< HTTPRequest > hreq) |
| static std::vector< std::pair< std::string, uint16_t > > | GetBindAddresses () |
| 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 (const std::string_view uri, const 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. | |
| bilingual_str | InvalidPortErrMsg (const std::string &optname, const std::string &invalid_value) |
Variables | |
| static constexpr auto | SELECT_TIMEOUT {50ms} |
| static constexpr int | SOCKET_OPTION_TRUE {1} |
| Explicit alias for setting socket option methods. | |
| static std::unique_ptr< HTTPServer > | g_http_server {nullptr} |
| HTTP module state. | |
| static GlobalMutex | g_httppathhandlers_mutex |
| Handlers for (sub)paths. | |
| static ThreadPool | g_threadpool_http ("http") |
| Http thread pool - future: encapsulate in HttpContext | |
| static int | g_max_queue_depth {100} |
|
static |
Definition at line 208 of file httpserver.cpp.
| std::optional< std::string > GetQueryParameterFromUri | ( | const std::string_view | uri, |
| const std::string_view | key ) |
Definition at line 673 of file httpserver.cpp.
|
static |
| bool InitHTTPServer | ( | ) |
Initialize HTTP server.
Call this before RegisterHTTPHandler or EventBase().
Definition at line 1351 of file httpserver.cpp.
| void InterruptHTTPServer | ( | ) |
Interrupt HTTP server threads.
Definition at line 1405 of file httpserver.cpp.
| bilingual_str common::InvalidPortErrMsg | ( | const std::string & | optname, |
| const std::string & | invalid_value ) |
|
static |
Definition at line 136 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.
|
static |
Definition at line 202 of file httpserver.cpp.
| std::string_view RequestMethodString | ( | HTTPRequestMethod | m | ) |
HTTP request method as string - use for logging only.
Definition at line 117 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 1397 of file httpserver.cpp.
| void StopHTTPServer | ( | ) |
Stop HTTP server.
Definition at line 1417 of file httpserver.cpp.
| void UnregisterHTTPHandler | ( | const std::string & | prefix, |
| bool | exactMatch ) |
Unregister handler for prefix.
Definition at line 248 of file httpserver.cpp.
|
static |
Definition at line 130 of file httpserver.cpp.
|
static |
HTTP module state.
Definition at line 69 of file httpserver.cpp.
|
static |
Handlers for (sub)paths.
Definition at line 71 of file httpserver.cpp.
|
static |
Definition at line 76 of file httpserver.cpp.
|
static |
|
staticconstexpr |
The set of sockets cannot be modified while waiting, so the sleep time needs to be small to avoid new sockets stalling.
Definition at line 47 of file httpserver.cpp.
|
staticconstexpr |
Explicit alias for setting socket option methods.
Definition at line 50 of file httpserver.cpp.