RESTinio
|
Context for handling http connections. More...
#include <connection.hpp>
Classes | |
struct | upgrade_internals_t |
Internals that are necessary for upgrade. More... | |
Public Types | |
using | timer_manager_t = typename Traits::timer_manager_t |
using | timer_guard_t = typename timer_manager_t::timer_guard_t |
using | request_handler_t = typename Traits::request_handler_t |
using | logger_t = typename Traits::logger_t |
using | strand_t = typename Traits::strand_t |
using | stream_socket_t = typename Traits::stream_socket_t |
using | lifetime_monitor_t = typename connection_count_limit_types< Traits >::lifetime_monitor_t |
Private Types | |
using | executor_wrapper_base_t = executor_wrapper_t< typename Traits::strand_t > |
using | none_write_operation_t = write_group_output_ctx_t::none_write_operation_t |
using | trivial_write_operation_t = write_group_output_ctx_t::trivial_write_operation_t |
using | file_write_operation_t = write_group_output_ctx_t::file_write_operation_t |
Private Member Functions | |
void | consume_message () |
Start (continue) a chain of read-parse-read-... operations. More... | |
void | after_read (const asio_ns::error_code &ec, std::size_t length) noexcept |
Handle read operation result. More... | |
void | consume_data (const char *data, std::size_t length) |
Parse some data. More... | |
void | on_request_message_complete () |
Handle a given request message. More... | |
void | handle_upgrade_request () |
Calls handler for upgrade request. More... | |
virtual void | write_response_parts (request_id_t request_id, response_output_flags_t response_output_flags, write_group_t wg) override |
Write parts for specified request. More... | |
void | write_response_parts_impl (request_id_t request_id, response_output_flags_t response_output_flags, write_group_t wg) |
Write parts for specified request. More... | |
void | init_write_if_necessary () |
void | init_write () |
Initiate write operation. More... | |
void | handle_current_write_ctx () noexcept |
Start/continue/continue handling output data of current write group. More... | |
void | handle_trivial_write_operation (const trivial_write_operation_t &op) |
Run trivial buffers write operation. More... | |
void | handle_file_write_operation (file_write_operation_t &op) |
Run sendfile write operation. More... | |
void | finish_handling_current_write_ctx () |
Do post write actions for current write group. More... | |
void | handle_nothing_to_write () |
void | after_write (const asio_ns::error_code &ec) noexcept |
Handle write response finished. More... | |
void | close () noexcept |
Close connection functions. More... | |
template<typename Message_Builder > | |
void | trigger_error_and_close (Message_Builder msg_builder) noexcept |
Trigger an error. More... | |
Private Attributes | |
stream_socket_t | m_socket |
Connection. More... | |
connection_settings_handle_t< Traits > | m_settings |
Common paramaters of a connection. More... | |
const endpoint_t | m_remote_endpoint |
Remote endpoint for this connection. More... | |
connection_input_t | m_input |
Input routine. More... | |
write_group_output_ctx_t | m_write_output_ctx |
Write to socket operation context. More... | |
bool | m_init_read_after_this_write { false } |
response_coordinator_t | m_response_coordinator |
Response coordinator. More... | |
request_handler_t & | m_request_handler |
Request handler. More... | |
logger_t & | m_logger |
Logger for operation. More... | |
lifetime_monitor_t | m_lifetime_monitor |
Monitor of the connection lifetime. More... | |
using | timout_cb_t = void(connection_t::*)(void) |
Callback type for timedout operations. More... | |
timout_cb_t | m_current_timeout_cb { nullptr } |
Callback to all if timeout happened. More... | |
std::chrono::steady_clock::time_point | m_current_timeout_after |
Timeout point of a current guarded operation. More... | |
timer_guard_t | m_timer_guard |
Timer guard. More... | |
tcp_connection_ctx_weak_handle_t | m_prepared_weak_ctx |
A prepared weak handle for passing it to timer guard. More... | |
virtual void | check_timeout (tcp_connection_ctx_handle_t &self) override |
Schedules real timedout operations check on the executer of a connection. More... | |
void | check_timeout_impl () |
Check timed out operation. More... | |
void | init_next_timeout_checking () |
Schedule next timeout checking. More... | |
void | cancel_timeout_checking () noexcept |
Stop timout guarding. More... | |
void | schedule_operation_timeout_callback (std::chrono::steady_clock::time_point timeout_after, timout_cb_t timout_cb) |
Helper function to work with timer guard. More... | |
void | schedule_operation_timeout_callback (std::chrono::steady_clock::duration timeout, timout_cb_t timout_cb) |
void | handle_xxx_timeout (const char *operation_name) |
void | handle_read_timeout () |
void | guard_read_operation () |
Statr guard read operation if necessary. More... | |
void | handle_request_handling_timeout () |
void | guard_request_handling_operation () |
Start guard request handling operation if necessary. More... | |
void | handle_write_response_timeout () |
void | guard_write_operation () |
Start guard write operation if necessary. More... | |
void | handle_sendfile_timeout () |
void | guard_sendfile_operation (std::chrono::steady_clock::duration timelimit) |
static connection_t & | cast_to_self (tcp_connection_ctx_base_t &base) |
Timer to controll operations. More... | |
Additional Inherited Members | |
![]() | |
template<typename Derived > | |
std::shared_ptr< Derived > | shared_from_concrete () |
Cast self to derived class. More... | |
Context for handling http connections.
Definition at line 303 of file connection.hpp.
|
private |
Definition at line 307 of file connection.hpp.
|
private |
Definition at line 1043 of file connection.hpp.
using restinio::impl::connection_t< Traits >::lifetime_monitor_t = typename connection_count_limit_types<Traits>::lifetime_monitor_t |
Definition at line 316 of file connection.hpp.
using restinio::impl::connection_t< Traits >::logger_t = typename Traits::logger_t |
Definition at line 313 of file connection.hpp.
|
private |
Definition at line 1041 of file connection.hpp.
using restinio::impl::connection_t< Traits >::request_handler_t = typename Traits::request_handler_t |
Definition at line 312 of file connection.hpp.
using restinio::impl::connection_t< Traits >::strand_t = typename Traits::strand_t |
Definition at line 314 of file connection.hpp.
using restinio::impl::connection_t< Traits >::stream_socket_t = typename Traits::stream_socket_t |
Definition at line 315 of file connection.hpp.
using restinio::impl::connection_t< Traits >::timer_guard_t = typename timer_manager_t::timer_guard_t |
Definition at line 311 of file connection.hpp.
using restinio::impl::connection_t< Traits >::timer_manager_t = typename Traits::timer_manager_t |
Definition at line 310 of file connection.hpp.
|
private |
Callback type for timedout operations.
Definition at line 1523 of file connection.hpp.
|
private |
Definition at line 1042 of file connection.hpp.
|
inline |
conn_id | Connection id. |
socket | Connection socket. |
settings | Settings that are common for connections. |
remote_endpoint | Remote endpoint for that connection. |
lifetime_monitor | Lifetime monitor to be used for handling connection count. |
Definition at line 319 of file connection.hpp.
|
delete |
|
delete |
|
inlineoverride |
Definition at line 360 of file connection.hpp.
|
inlineprivatenoexcept |
Handle read operation result.
Definition at line 509 of file connection.hpp.
|
inlineprivatenoexcept |
Handle write response finished.
Definition at line 1339 of file connection.hpp.
|
inlineprivatenoexcept |
Stop timout guarding.
Definition at line 1559 of file connection.hpp.
|
inlinestaticprivate |
Timer to controll operations.
Check timeouts for all activities.
Definition at line 1488 of file connection.hpp.
|
inlineoverrideprivatevirtual |
Schedules real timedout operations check on the executer of a connection.
Definition at line 1496 of file connection.hpp.
|
inlineprivate |
Check timed out operation.
Definition at line 1537 of file connection.hpp.
|
inlineprivatenoexcept |
|
inlineprivate |
Parse some data.
Definition at line 578 of file connection.hpp.
|
inlineprivate |
Start (continue) a chain of read-parse-read-... operations.
Definition at line 473 of file connection.hpp.
|
inlineprivate |
Do post write actions for current write group.
Definition at line 1234 of file connection.hpp.
|
inlineprivate |
Statr guard read operation if necessary.
Definition at line 1606 of file connection.hpp.
|
inlineprivate |
Start guard request handling operation if necessary.
Definition at line 1624 of file connection.hpp.
|
inlineprivate |
Definition at line 1656 of file connection.hpp.
|
inlineprivate |
Start guard write operation if necessary.
Definition at line 1642 of file connection.hpp.
|
inlineprivatenoexcept |
Start/continue/continue handling output data of current write group.
This function is a starting point of a loop process of sending data from a given write group. It extracts the next bunch of trivial buffers or a sendfile-runner and starts an appropriate write operation. In data of a given write group finishes, finish_handling_current_write_ctx() is invoked thus breaking the loop.
Definition at line 1058 of file connection.hpp.
|
inlineprivate |
Run sendfile write operation.
Definition at line 1154 of file connection.hpp.
|
inlineprivate |
Definition at line 1293 of file connection.hpp.
|
inlineprivate |
Definition at line 1599 of file connection.hpp.
|
inlineprivate |
Definition at line 1617 of file connection.hpp.
|
inlineprivate |
Definition at line 1650 of file connection.hpp.
|
inlineprivate |
Run trivial buffers write operation.
Definition at line 1091 of file connection.hpp.
|
inlineprivate |
Calls handler for upgrade request.
Request data must be in input context (m_input).
Definition at line 747 of file connection.hpp.
|
inlineprivate |
Definition at line 1635 of file connection.hpp.
|
inlineprivate |
Definition at line 1586 of file connection.hpp.
|
inline |
Definition at line 371 of file connection.hpp.
|
inlineprivate |
Schedule next timeout checking.
Definition at line 1552 of file connection.hpp.
|
inlineprivate |
Initiate write operation.
Definition at line 972 of file connection.hpp.
|
inlineprivate |
Definition at line 960 of file connection.hpp.
|
inline |
Move socket out of connection.
Definition at line 461 of file connection.hpp.
|
inlineprivate |
Handle a given request message.
Definition at line 625 of file connection.hpp.
|
delete |
|
delete |
|
inlineprivate |
Definition at line 1576 of file connection.hpp.
|
inlineprivate |
Helper function to work with timer guard.
Definition at line 1567 of file connection.hpp.
|
inlineprivatenoexcept |
Trigger an error.
Closes the connection and write to log an error message.
Definition at line 1451 of file connection.hpp.
|
inline |
Start reading next htttp-message.
Definition at line 408 of file connection.hpp.
|
inlineoverrideprivatevirtual |
Write parts for specified request.
Run write message on io_context loop if possible.
request_id | Request id. |
response_output_flags | Resp output flag. |
wg | Part of the response data. |
Implements restinio::impl::connection_base_t.
Definition at line 828 of file connection.hpp.
|
inlineprivate |
Write parts for specified request.
request_id | Request id. |
response_output_flags | Resp output flag. |
wg | Part of the response data. |
Definition at line 868 of file connection.hpp.
|
private |
Timeout point of a current guarded operation.
Definition at line 1529 of file connection.hpp.
|
private |
Callback to all if timeout happened.
Definition at line 1526 of file connection.hpp.
|
private |
Definition at line 1478 of file connection.hpp.
|
private |
Input routine.
Definition at line 1472 of file connection.hpp.
|
private |
Monitor of the connection lifetime.
It's required for controlling the count of active parallel connections.
Definition at line 1681 of file connection.hpp.
|
private |
Logger for operation.
Definition at line 1671 of file connection.hpp.
|
private |
A prepared weak handle for passing it to timer guard.
Definition at line 1533 of file connection.hpp.
|
private |
Remote endpoint for this connection.
Definition at line 1469 of file connection.hpp.
|
private |
Request handler.
Definition at line 1668 of file connection.hpp.
|
private |
Response coordinator.
Definition at line 1481 of file connection.hpp.
|
private |
Common paramaters of a connection.
Definition at line 1466 of file connection.hpp.
|
private |
Connection.
Definition at line 1463 of file connection.hpp.
|
private |
Timer guard.
Definition at line 1531 of file connection.hpp.
|
private |
Write to socket operation context.
Definition at line 1475 of file connection.hpp.