Bitcoin Core 31.99.0
P2P Digital Currency
httpserver.h
Go to the documentation of this file.
1// Copyright (c) 2015-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_HTTPSERVER_H
6#define BITCOIN_HTTPSERVER_H
7
8#include <atomic>
9#include <functional>
10#include <memory>
11#include <optional>
12#include <span>
13#include <stdexcept>
14#include <string>
15#include <vector>
16
17#include <netaddress.h>
18#include <rpc/protocol.h>
19#include <util/byte_units.h>
20#include <util/expected.h>
21#include <util/sock.h>
22#include <util/strencodings.h>
23#include <util/string.h>
24#include <util/threadinterrupt.h>
25#include <util/time.h>
26
27namespace util {
28class SignalInterrupt;
29} // namespace util
30
34inline constexpr int DEFAULT_HTTP_THREADS=16;
35
40inline constexpr int DEFAULT_HTTP_WORKQUEUE=64;
41
42inline constexpr int DEFAULT_HTTP_SERVER_TIMEOUT=30;
43
47inline constexpr int DEFAULT_MAX_HTTP_CONNECTIONS = 16;
48
50 UNKNOWN,
51 GET,
52 POST,
53 HEAD,
54 PUT
55};
56
57class HTTPRequest;
58
60using HTTPRequestHandler = std::function<void(HTTPRequest* req, const std::string&)>;
61
66void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler);
68void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch);
69
70namespace bitcoin_http {
72inline constexpr size_t MIN_REQUEST_LINE_LENGTH = std::string_view("GET / HTTP/1.0").size();
73
78inline constexpr size_t MAX_HEADERS_SIZE{8192};
79
81inline constexpr uint64_t MAX_BODY_SIZE{32_MiB};
82
85struct ContentTooLargeError : std::runtime_error {
86 using std::runtime_error::runtime_error;
87};
88} // namespace bitcoin_http
89
91{
92public:
98 std::optional<std::string> FindFirst(std::string_view key) const;
103 std::vector<std::string_view> FindAll(std::string_view key) const;
104 void Write(std::string&& key, std::string&& value);
108 void RemoveAll(std::string_view key);
118 bool Read(util::LineReader& reader, bool write = true);
119 std::string Stringify() const;
120
121private:
126 std::vector<std::pair<std::string, std::string>> m_headers;
127
129 size_t m_consumed{0};
130};
131
138 uint8_t major{1};
139 uint8_t minor{1};
141};
142
143struct HTTPResponse {
147
148 std::string StringifyHeaders() const;
149};
150
151class HTTPRemoteClient;
152
154{
155public:
156 explicit HTTPRequest(const std::shared_ptr<HTTPRemoteClient>& client) : m_client{client} {}
158 explicit HTTPRequest() : m_client{} {}
159
173
174 void WriteReply(HTTPStatusCode status, std::span<const std::byte> reply_body = {});
175 void WriteReply(HTTPStatusCode status, std::string_view reply_body_view)
176 {
177 WriteReply(status, std::as_bytes(std::span{reply_body_view}));
178 }
179
180 const HTTPVersion& GetVersion() const { return m_version; }
181 std::shared_ptr<HTTPRemoteClient> GetClient() const { return m_client.lock(); }
182
183 // These methods reimplement the API from http_libevent::HTTPRequest
184 // for downstream JSONRPC and REST modules.
185 std::string GetURI() const { return m_target; }
186 CService GetPeer() const;
188 std::optional<std::string> GetQueryParameter(std::string_view key) const;
189 std::optional<std::string> GetHeader(std::string_view hdr) const;
190 std::string ReadBody() const { return m_body; }
191 void WriteHeader(std::string&& hdr, std::string&& value);
192 std::optional<uint64_t> GetChunkSize() const { return m_chunk_size; }
193 uint64_t GetChunkProgress() const { return m_chunk_read; }
194
195 enum class State {
196 Init,
197 NeedsHeaders,
198 NeedsBody,
199 Complete,
200 Error
201 };
202 State GetState() const { return m_state; }
203 void SetState(State state) { m_state = state; }
204
205private:
207 std::string m_target;
210 std::string m_body;
211
213 std::weak_ptr<HTTPRemoteClient> m_client;
214
217
218 // If a large request is sent with "Transfer-encoding: chunked" we may
219 // read the chunk size in a separate I/O loop iteration than the chunk
220 // of data itself. Store the chunk size value here until the chunk is read.
221 std::optional<uint64_t> m_chunk_size;
222 // We may also read a large chunk over multiple loop iterations.
223 // Track the progress of the chunk here.
224 uint64_t m_chunk_read{0};
225
227};
228
230{
231public:
235 using Id = uint64_t;
236
237 explicit HTTPServer(std::function<void(std::unique_ptr<HTTPRequest>&&)> func)
238 : m_request_dispatcher{std::move(func)} {}
239
240 virtual ~HTTPServer()
241 {
242 Assume(!m_thread_socket_handler.joinable()); // Missing call to JoinSocketsThreads()
243 Assume(m_connected.empty()); // Missing call to DisconnectClients(), or disconnect flags not set
244 Assume(m_listen.empty()); // Missing call to StopListening()
245 }
246
250 bool InitHTTPAllowList();
251
258
262 void StopListening();
263
267 size_t GetListeningSocketCount() const { return m_listen.size(); }
268
272 size_t GetConnectionsCount() const { return m_connected_size.load(std::memory_order_acquire); }
273
277 void StartSocketsThreads();
278
282 void JoinSocketsThreads();
283
288
293
298 void SetRequestHandler(std::function<void(std::unique_ptr<HTTPRequest>&&)> func)
300 {
302 m_request_dispatcher = std::move(func));
303 }
304
312
316 void SetServerTimeout(std::chrono::seconds seconds) { m_rpcservertimeout = seconds; }
317
321 void SetMaxConnections(int max_conn) { m_rpcmaxconnections = max_conn; }
322
328
329private:
333 std::vector<std::shared_ptr<Sock>> m_listen;
334
338 std::atomic<Id> m_next_id{0};
339
346 std::vector<std::shared_ptr<HTTPRemoteClient>> m_connected;
347
352 std::atomic_bool m_stop_accepting{false};
353
359 std::atomic_bool m_disconnect_all_clients{false};
360
366 std::atomic<size_t> m_connected_size{0};
367
372 struct IOReadiness {
379
385 std::unordered_map<Sock::EventsPerSock::key_type,
386 std::shared_ptr<HTTPRemoteClient>,
390 };
391
396
402
403 /*
404 * What to do with HTTP requests once received, validated and parsed.
405 * Set in main thread by server start and interrupt but read in
406 * worker threads.
407 */
410 std::function<void(std::unique_ptr<HTTPRequest>&&)> m_request_dispatcher GUARDED_BY(m_request_dispatcher_mutex);
412
417
421 std::vector<CSubNet> m_allow_subnets;
422
426 bool ClientAllowed(const CNetAddr& netaddr) const;
427
432
439 std::unique_ptr<Sock> AcceptConnection(const Sock& listen_sock, CService& addr);
440
444 Id GetNewId();
445
452 void NewSockAccepted(std::unique_ptr<Sock>&& sock, const CService& addr);
453
458 void SocketHandlerConnected(const IOReadiness& io_readiness) const
460
465 void SocketHandlerListening(const Sock::EventsPerSock& events_per_sock);
466
472 IOReadiness GenerateWaitSockets() const;
473
479
486 void DisconnectClients();
487};
488
489std::optional<std::string> GetQueryParameterFromUri(std::string_view uri, std::string_view key);
490
492{
493public:
494 explicit HTTPRemoteClient(HTTPServer::Id id, const CService& addr, std::unique_ptr<Sock> socket)
495 : m_id(id), m_addr(addr), m_origin(addr.ToStringAddrPort()), m_sock{std::move(socket)}, m_idle_since{Now<SteadySeconds>()} {}
496
497 // Disable copies (should only be used as shared pointers)
500
501 const std::string& GetOrigin() const { return m_origin; }
502 const CService& GetPeer() const { return m_addr; }
503 std::shared_ptr<Sock> GetSock() EXCLUSIVE_LOCKS_REQUIRED(!m_sock_mutex) { return WITH_LOCK(m_sock_mutex, return m_sock;); }
504 bool ReadyToSend() const EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex) { return WITH_LOCK(m_send_mutex, return m_send_ready;); }
505 bool ReceiveBufferEmpty() const { return m_recv_buffer.empty(); }
506
507 void Send(const HTTPResponse& res, std::span<const std::byte> reply_body, bool keep_alive) EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex, !m_sock_mutex);
508 void Receive() EXCLUSIVE_LOCKS_REQUIRED(!m_sock_mutex);
509
510 bool MaybeDisconnect(std::chrono::time_point<SteadyClock> now, std::chrono::seconds rpcservertimeout, bool disconnect_all);
511
518 static std::unique_ptr<HTTPRequest> TryReadRequest(const std::shared_ptr<HTTPRemoteClient>& client);
519
524 bool MaybeSendBytesFromBuffer() EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex, !m_sock_mutex);
525
531 const HTTPRequest* GetRequest() const { return m_req.get(); }
532
534 const std::string& GetRecvBuffer() const { return m_recv_buffer; }
535
536protected:
538 std::string& MutateRecvBuffer() { return m_recv_buffer; }
539
540private:
547 void ReadRequest(HTTPRequest& req);
548
551
554
556 const std::string m_origin;
557
563 std::string m_recv_buffer{};
564
568 std::unique_ptr<HTTPRequest> m_req;
569
573 std::atomic_bool m_req_busy{false};
574
581 std::vector<std::byte> m_send_buffer GUARDED_BY(m_send_mutex);
583
592 bool m_send_ready GUARDED_BY(m_send_mutex){false};
593
600
608 std::shared_ptr<Sock> m_sock GUARDED_BY(m_sock_mutex);
609
616 std::atomic_bool m_connection_busy{true};
617
621 std::atomic_bool m_keep_alive{false};
622
628 std::atomic_bool m_disconnect{false};
629
633 std::atomic<SteadySeconds> m_idle_since;
634};
635
639bool InitHTTPServer();
640
645void StartHTTPServer();
646
649
651void StopHTTPServer();
652
653#endif // BITCOIN_HTTPSERVER_H
#define Assume(val)
Assume is the identity function.
Definition: check.h:128
Network address.
Definition: netaddress.h:113
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:531
A helper class for interruptible sleeps.
std::optional< std::string > FindFirst(std::string_view key) const
Definition: httpserver.cpp:265
size_t m_consumed
Track total bytes consumed in Read() for limit checks.
Definition: httpserver.h:129
void RemoveAll(std::string_view key)
Definition: httpserver.cpp:291
std::vector< std::pair< std::string, std::string > > m_headers
Headers can have duplicate field names, so we use a vector of key-value pairs instead of a map.
Definition: httpserver.h:126
bool Read(util::LineReader &reader, bool write=true)
Definition: httpserver.cpp:299
std::string Stringify() const
Definition: httpserver.cpp:355
void Write(std::string &&key, std::string &&value)
Definition: httpserver.cpp:286
std::vector< std::string_view > FindAll(std::string_view key) const
Definition: httpserver.cpp:275
bool ReceiveBufferEmpty() const
Definition: httpserver.h:505
const std::string & GetRecvBuffer() const
Used for tests.
Definition: httpserver.h:534
bool m_send_ready GUARDED_BY(m_send_mutex)
Set true by worker threads after writing a response to m_send_buffer.
Definition: httpserver.h:592
std::vector< std::byte > m_send_buffer GUARDED_BY(m_send_mutex)
Mutex m_send_mutex
Response data destined for this client.
Definition: httpserver.h:580
std::string & MutateRecvBuffer()
Used for tests.
Definition: httpserver.h:538
const std::string & GetOrigin() const
Definition: httpserver.h:501
bool ReadyToSend() const EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex)
Definition: httpserver.h:504
const std::string m_origin
IP:port of connected client, cached for logging purposes.
Definition: httpserver.h:556
const CService & GetPeer() const
Definition: httpserver.h:502
const HTTPServer::Id m_id
ID provided by HTTPServer upon connection and instantiation.
Definition: httpserver.h:550
HTTPRemoteClient(HTTPServer::Id id, const CService &addr, std::unique_ptr< Sock > socket)
Definition: httpserver.h:494
std::shared_ptr< Sock > m_sock GUARDED_BY(m_sock_mutex)
Underlying socket.
std::shared_ptr< Sock > GetSock() EXCLUSIVE_LOCKS_REQUIRED(!m_sock_mutex)
Definition: httpserver.h:503
std::atomic< SteadySeconds > m_idle_since
Timestamp of last send or receive activity, used for -rpcservertimeout.
Definition: httpserver.h:633
std::unique_ptr< HTTPRequest > m_req
Requests from a client must be processed in the order in which they were received,...
Definition: httpserver.h:568
Mutex m_sock_mutex
Mutex that serializes the Send() and Recv() calls on m_sock.
Definition: httpserver.h:599
const CService m_addr
Remote address of connected client.
Definition: httpserver.h:553
HTTPRemoteClient(const HTTPRemoteClient &)=delete
HTTPRemoteClient & operator=(const HTTPRemoteClient &)=delete
void WriteHeader(std::string &&hdr, std::string &&value)
Definition: httpserver.cpp:703
const HTTPVersion & GetVersion() const
Definition: httpserver.h:180
std::optional< uint64_t > m_chunk_size
Definition: httpserver.h:221
std::optional< std::string > GetQueryParameter(std::string_view key) const
Definition: httpserver.cpp:666
std::string GetURI() const
Definition: httpserver.h:185
State m_state
Definition: httpserver.h:226
std::string m_target
Definition: httpserver.h:207
bool LoadHeaders(util::LineReader &reader)
Definition: httpserver.cpp:426
HTTPHeaders m_headers
Definition: httpserver.h:209
void WriteReply(HTTPStatusCode status, std::string_view reply_body_view)
Definition: httpserver.h:175
bool LoadControlData(util::LineReader &reader)
Methods that attempt to parse HTTP request fields line-by-line from a receive buffer.
Definition: httpserver.cpp:378
HTTPVersion m_version
Definition: httpserver.h:208
uint64_t m_chunk_read
Definition: httpserver.h:224
std::weak_ptr< HTTPRemoteClient > m_client
Pointer to the client that made the request so we know who to respond to.
Definition: httpserver.h:213
std::optional< std::string > GetHeader(std::string_view hdr) const
Definition: httpserver.cpp:698
HTTPRequest()
Construct with a null client for unit tests.
Definition: httpserver.h:158
HTTPRequestMethod m_method
Definition: httpserver.h:206
std::shared_ptr< HTTPRemoteClient > GetClient() const
Definition: httpserver.h:181
HTTPRequestMethod GetRequestMethod() const
Definition: httpserver.h:187
std::string m_body
Definition: httpserver.h:210
std::string ReadBody() const
Definition: httpserver.h:190
HTTPRequest(const std::shared_ptr< HTTPRemoteClient > &client)
Definition: httpserver.h:156
bool LoadBody(util::LineReader &reader)
Definition: httpserver.cpp:431
uint64_t GetChunkProgress() const
Definition: httpserver.h:193
void SetState(State state)
Definition: httpserver.h:203
void WriteReply(HTTPStatusCode status, std::span< const std::byte > reply_body={})
Definition: httpserver.cpp:535
State GetState() const
Definition: httpserver.h:202
CService GetPeer() const
Definition: httpserver.cpp:657
std::optional< uint64_t > GetChunkSize() const
Definition: httpserver.h:192
HTTPHeaders m_response_headers
Response headers may be set in advance before response body is known.
Definition: httpserver.h:216
std::atomic< Id > m_next_id
The id to assign to the next created connection.
Definition: httpserver.h:338
HTTPServer(std::function< void(std::unique_ptr< HTTPRequest > &&)> func)
Definition: httpserver.h:237
void ThreadSocketHandler() EXCLUSIVE_LOCKS_REQUIRED(!m_request_dispatcher_mutex)
Check connected and listening sockets for IO readiness and process them accordingly.
void JoinSocketsThreads()
Join (wait for) the threads started by StartSocketsThreads() to exit.
Definition: httpserver.cpp:813
std::function< void(std::unique_ptr< HTTPRequest > &&)> m_request_dispatcher GUARDED_BY(m_request_dispatcher_mutex)
void InterruptNet()
Stop network activity.
Definition: httpserver.h:287
std::vector< std::shared_ptr< HTTPRemoteClient > > m_connected
List of HTTPRemoteClients with connected sockets.
Definition: httpserver.h:346
int m_rpcmaxconnections
Maximum amount of concurrent connections.
Definition: httpserver.h:431
void StopAccepting()
Stop accepting new connections in the I/O loop.
Definition: httpserver.h:311
CThreadInterrupt m_interrupt_net
This is signaled when network activity should cease.
Definition: httpserver.h:395
void SocketHandlerConnected(const IOReadiness &io_readiness) const EXCLUSIVE_LOCKS_REQUIRED(!m_request_dispatcher_mutex)
Do the read/write for connected sockets that are ready for IO.
Definition: httpserver.cpp:890
std::atomic_bool m_disconnect_all_clients
Flag used during shutdown.
Definition: httpserver.h:359
Id GetNewId()
Generate an id for a newly created connection.
Definition: httpserver.cpp:858
void SetMaxConnections(int max_conn)
Set the maximum amount of connected HTTPClients (-rpcmaxconnections)
Definition: httpserver.h:321
void DisconnectClients()
Close underlying socket connections for flagged clients by removing their shared pointer from m_conne...
util::Expected< void, std::string > BindAndStartListening(const CService &to)
Bind to a new address:port, start listening and add the listen socket to m_listen.
Definition: httpserver.cpp:708
std::vector< CSubNet > m_allow_subnets
List of subnets to allow HTTP connections from.
Definition: httpserver.h:421
void ClearConnectedClients()
Force-remove all remaining clients from m_connected without waiting for graceful disconnection.
std::atomic< size_t > m_connected_size
The number of connected sockets.
Definition: httpserver.h:366
std::vector< std::shared_ptr< Sock > > m_listen
List of listening sockets.
Definition: httpserver.h:333
std::atomic_bool m_stop_accepting
Flag used during shutdown to stop accepting new connections.
Definition: httpserver.h:352
void SocketHandlerListening(const Sock::EventsPerSock &events_per_sock)
Accept incoming connections, one from each read-ready listening socket.
Definition: httpserver.cpp:972
IOReadiness GenerateWaitSockets() const
Generate a collection of sockets to check for IO readiness.
Definition: httpserver.cpp:994
std::thread m_thread_socket_handler
Thread that sends to and receives from sockets and accepts connections.
Definition: httpserver.h:401
uint64_t Id
Each connection is assigned an unique id of this type.
Definition: httpserver.h:235
std::chrono::seconds m_rpcservertimeout
Idle timeout after which clients are disconnected.
Definition: httpserver.h:416
void SetServerTimeout(std::chrono::seconds seconds)
Set the idle client timeout (-rpcservertimeout)
Definition: httpserver.h:316
void StopListening()
Stop listening by closing all listening sockets.
Definition: httpserver.cpp:796
size_t GetConnectionsCount() const
Get the number of HTTPRemoteClients we are connected to.
Definition: httpserver.h:272
void NewSockAccepted(std::unique_ptr< Sock > &&sock, const CService &addr)
After a new socket with a client has been created, configure its flags, make a new HTTPRemoteClient a...
Definition: httpserver.cpp:863
void SetRequestHandler(std::function< void(std::unique_ptr< HTTPRequest > &&)> func) EXCLUSIVE_LOCKS_REQUIRED(!m_request_dispatcher_mutex)
Update the request handler method.
Definition: httpserver.h:298
virtual ~HTTPServer()
Definition: httpserver.h:240
bool ClientAllowed(const CNetAddr &netaddr) const
Check an incoming connection's source IP against the allow list.
Definition: httpserver.cpp:79
size_t GetListeningSocketCount() const
Get the number of sockets the server is bound to and listening on.
Definition: httpserver.h:267
bool InitHTTPAllowList()
Parse the user's -rpcallowip settings and populate m_allow_subnets.
Definition: httpserver.cpp:90
void DisconnectAllClients()
Start disconnecting clients when possible in the I/O loop.
Definition: httpserver.h:292
Mutex m_request_dispatcher_mutex
Definition: httpserver.h:409
std::unique_ptr< Sock > AcceptConnection(const Sock &listen_sock, CService &addr)
Accept a connection.
Definition: httpserver.cpp:820
void StartSocketsThreads()
Start the necessary threads for sockets IO.
Definition: httpserver.cpp:801
Definition: init.h:13
RAII helper class that manages a socket and closes it automatically when it goes out of scope.
Definition: sock.h:35
std::unordered_map< std::shared_ptr< const Sock >, Events, HashSharedPtrSock, EqualSharedPtrSock > EventsPerSock
On which socket to wait for what events in WaitMany().
Definition: sock.h:216
The util::Expected class provides a standard way for low-level functions to return either error value...
Definition: expected.h:44
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
void InterruptHTTPServer()
Interrupt HTTP server threads.
constexpr int DEFAULT_MAX_HTTP_CONNECTIONS
Maximum number of connected HTTP clients.
Definition: httpserver.h:47
void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch)
Unregister handler for prefix.
Definition: httpserver.cpp:248
void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler)
Register handler for prefix.
Definition: httpserver.cpp:241
std::function< void(HTTPRequest *req, const std::string &)> HTTPRequestHandler
Handler for requests to a certain HTTP path.
Definition: httpserver.h:60
void StartHTTPServer()
Start HTTP server.
constexpr int DEFAULT_HTTP_SERVER_TIMEOUT
Definition: httpserver.h:42
bool InitHTTPServer()
Initialize HTTP server.
constexpr int DEFAULT_HTTP_THREADS
The default value for -rpcthreads.
Definition: httpserver.h:34
constexpr int DEFAULT_HTTP_WORKQUEUE
The default value for -rpcworkqueue.
Definition: httpserver.h:40
HTTPRequestMethod
Definition: httpserver.h:49
void StopHTTPServer()
Stop HTTP server.
std::optional< std::string > GetQueryParameterFromUri(std::string_view uri, std::string_view key)
Definition: httpserver.cpp:673
util::LineReader reader
std::unique_ptr< ProxyClient< messages::FooInterface > > client
std::thread thread
Thread variable should be after other struct members so the thread does not start until the other mem...
constexpr uint64_t MAX_BODY_SIZE
Maximum size of an HTTP request body.
Definition: httpserver.h:81
constexpr size_t MIN_REQUEST_LINE_LENGTH
Shortest valid request line, used by libevent in evhttp_parse_request_line()
Definition: httpserver.h:72
constexpr size_t MAX_HEADERS_SIZE
Maximum size of each headers line in an HTTP request, also the maximum size of all headers total.
Definition: httpserver.h:78
const char * prefix
Definition: rest.cpp:1195
bool(* handler)(const std::any &context, HTTPRequest *req, const std::string &strReq)
Definition: rest.cpp:1196
HTTPStatusCode
HTTP status codes.
Definition: protocol.h:13
@ HTTP_INTERNAL_SERVER_ERROR
Definition: protocol.h:22
HTTPVersion version
Definition: httpserver.h:144
std::string StringifyHeaders() const
Definition: httpserver.cpp:368
HTTPHeaders headers
Definition: httpserver.h:146
Info about which socket has which event ready and a reverse map back to the HTTPRemoteClient that own...
Definition: httpserver.h:372
std::unordered_map< Sock::EventsPerSock::key_type, std::shared_ptr< HTTPRemoteClient >, Sock::HashSharedPtrSock, Sock::EqualSharedPtrSock > httpclients_per_sock
Map of socket -> HTTPRemoteClient.
Definition: httpserver.h:389
Sock::EventsPerSock events_per_sock
Map of socket -> socket events.
Definition: httpserver.h:378
uint8_t minor
Definition: httpserver.h:139
uint8_t major
Default HTTP protocol version 1.1 is used by error responses when a request is unreadable.
Definition: httpserver.h:138
Thrown when a request body exceeds MAX_BODY_SIZE (or will exceed, in chunked transfer) so the server ...
Definition: httpserver.h:85
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:299
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
std::chrono::steady_clock SteadyClock
Definition: time.h:37
T Now()
Return the current time point cast to the given precision.
Definition: time.h:127
std::chrono::time_point< std::chrono::steady_clock, std::chrono::seconds > SteadySeconds
Definition: time.h:38