#include <httpserver.h>
Definition at line 491 of file httpserver.h.
◆ HTTPRemoteClient() [1/2]
◆ HTTPRemoteClient() [2/2]
◆ GetOrigin()
| const std::string & HTTPRemoteClient::GetOrigin |
( |
| ) |
const |
|
inline |
◆ GetPeer()
| const CService & HTTPRemoteClient::GetPeer |
( |
| ) |
const |
|
inline |
◆ GetRecvBuffer()
| const std::string & HTTPRemoteClient::GetRecvBuffer |
( |
| ) |
const |
|
inline |
◆ GetRequest()
| const HTTPRequest * HTTPRemoteClient::GetRequest |
( |
| ) |
const |
|
inline |
◆ GetSock()
| std::shared_ptr< Sock > HTTPRemoteClient::GetSock |
( |
| ) |
|
|
inline |
◆ GUARDED_BY() [1/3]
| std::vector< std::byte > m_send_buffer HTTPRemoteClient::GUARDED_BY |
( |
m_send_mutex |
| ) |
|
|
private |
◆ GUARDED_BY() [2/3]
| bool m_send_ready HTTPRemoteClient::GUARDED_BY |
( |
m_send_mutex |
| ) |
|
|
inlineprivate |
Set true by worker threads after writing a response to m_send_buffer.
Set false by the HTTPServer I/O thread after flushing m_send_buffer. Checked in the HTTPServer I/O loop to decide whether to poll the socket for writeability or readability. Guarded by m_send_mutex so it stays consistent with m_send_buffer's emptiness: the two must always be updated together under the same lock.
Definition at line 586 of file httpserver.h.
◆ GUARDED_BY() [3/3]
Underlying socket.
shared_ptr (instead of unique_ptr) is used to avoid premature close of the underlying file descriptor by one thread while another thread is poll(2)-ing it for activity.
- See also
- https://github.com/bitcoin/bitcoin/issues/21744 for details.
◆ MaybeDisconnect()
| bool HTTPRemoteClient::MaybeDisconnect |
( |
std::chrono::time_point< SteadyClock > |
now, |
|
|
std::chrono::seconds |
rpcservertimeout, |
|
|
bool |
disconnect_all |
|
) |
| |
◆ MaybeSendBytesFromBuffer()
| bool HTTPRemoteClient::MaybeSendBytesFromBuffer |
( |
| ) |
|
Push data (if there is any) from client's m_send_buffer to the connected socket.
- Returns
- false if we are done with this client and HTTPServer can skip the next read operation from it.
Definition at line 1212 of file httpserver.cpp.
◆ MutateRecvBuffer()
| std::string & HTTPRemoteClient::MutateRecvBuffer |
( |
| ) |
|
|
inlineprotected |
◆ operator=()
◆ ReadRequest()
| void HTTPRemoteClient::ReadRequest |
( |
HTTPRequest & |
req | ) |
|
|
private |
Try to read an HTTP request from the receive buffer.
Updates HTTPRequest.m_state and drains buffer on error.
- Parameters
-
- Exceptions
-
| std::runtime_error | if request is unreadable or violates protocol |
Definition at line 1169 of file httpserver.cpp.
◆ ReadyToSend()
| bool HTTPRemoteClient::ReadyToSend |
( |
| ) |
const |
|
inline |
◆ Receive()
| void HTTPRemoteClient::Receive |
( |
| ) |
|
◆ Send()
| void HTTPRemoteClient::Send |
( |
const HTTPResponse & |
res, |
|
|
std::span< const std::byte > |
reply_body, |
|
|
bool |
keep_alive |
|
) |
| |
◆ TryReadRequest()
Try to read an HTTPRequest from a client's receive buffer.
Only complete requests are returned, incomplete requests are left in the buffer to wait for more data. Some read errors will mark this client for disconnection.
Definition at line 1041 of file httpserver.cpp.
◆ !m_sock_mutex [1/2]
| void HTTPRemoteClient::!m_sock_mutex |
◆ !m_sock_mutex [2/2]
| bool HTTPRemoteClient::!m_sock_mutex |
◆ m_addr
Remote address of connected client.
Definition at line 548 of file httpserver.h.
◆ m_connection_busy
| std::atomic_bool HTTPRemoteClient::m_connection_busy {true} |
|
private |
Initialized to true while server waits for first request from client.
Set to false after data is written to m_send_buffer and then that buffer is flushed to client. Reset to true when we receive new request data from client. Checked during DisconnectClients() and set by read/write operations called in either the HTTPServer I/O loop or by a worker thread during an "optimistic send". m_connection_busy=true can be overridden by m_disconnect=true (we disconnect).
Definition at line 610 of file httpserver.h.
◆ m_disconnect
| std::atomic_bool HTTPRemoteClient::m_disconnect {false} |
|
private |
Flag this client for disconnection on next loop.
Either we have encountered a permanent error, or both sides of the socket are done with the connection, e.g. our reply to a "Connection: close" request has been sent. Might be set in a worker thread or in the I/O thread. When set to true we disconnect, possibly overriding all other disconnect flags.
Definition at line 622 of file httpserver.h.
◆ m_id
◆ m_idle_since
Timestamp of last send or receive activity, used for -rpcservertimeout.
Due to optimistic sends it may be updated in either a worker thread or in the I/O thread. It is checked in the I/O thread to disconnect idle clients.
Definition at line 627 of file httpserver.h.
◆ m_keep_alive
| std::atomic_bool HTTPRemoteClient::m_keep_alive {false} |
|
private |
Client has requested to keep the connection open after all requests have been responded to.
Set by (potentially multiple) worker threads and checked in the HTTPServer I/O loop. m_keep_alive=true can be overridden by HTTPServer.m_disconnect_all_clients (we disconnect).
Definition at line 615 of file httpserver.h.
◆ m_origin
| const std::string HTTPRemoteClient::m_origin |
|
private |
IP:port of connected client, cached for logging purposes.
Definition at line 551 of file httpserver.h.
◆ m_recv_buffer
| std::string HTTPRemoteClient::m_recv_buffer {} |
|
private |
In lieu of an intermediate transport class like p2p uses, we copy data from the socket buffer to the client object and attempt to read HTTP requests from here.
Definition at line 558 of file httpserver.h.
◆ m_req
Requests from a client must be processed in the order in which they were received, blocking on a per-client basis.
We read one request at a time from the socket buffer then pass it to a worker.
Definition at line 563 of file httpserver.h.
◆ m_req_busy
| std::atomic_bool HTTPRemoteClient::m_req_busy {false} |
|
private |
Set to true by the I/O thread when a request is popped off and passed to a worker thread, reset to false by the worker thread.
Definition at line 567 of file httpserver.h.
◆ m_send_mutex
| Mutex HTTPRemoteClient::m_send_mutex |
|
mutableprivate |
Response data destined for this client.
Written to by http worker threads, read and erased by HTTPServer I/O thread
Definition at line 574 of file httpserver.h.
◆ m_sock_mutex
| Mutex HTTPRemoteClient::m_sock_mutex |
|
private |
Mutex that serializes the Send() and Recv() calls on m_sock.
Reading from the client occurs in the I/O thread but writing back to a client may occur in a worker thread.
Definition at line 593 of file httpserver.h.
The documentation for this class was generated from the following files: