Refactored MHD_connection_get_info_dynamic_sz() and relevant types

Resulting values now are individual for each query value.
This commit is contained in:
Evgeny Grin (Karlson2k)
2025-03-22 16:39:45 +03:00
parent d5687d586c
commit e62dfcac0e
3 changed files with 27 additions and 24 deletions
+11 -10
View File
@@ -9751,14 +9751,14 @@ enum MHD_ConnectionInfoDynamicType
* automatically disconnected.
* Note: the value set is NOT the number of seconds left before automatic
* disconnection.
* The result is placed in @a v_uint member.
* The result is placed in @a v_connection_timeout_uint member.
* @ingroup request
*/
MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_TIMEOUT = 10
,
/**
* Check whether the connection is suspended.
* The result is placed in @a v_bool member.
* The result is placed in @a v_connection_suspended_bool member.
* @ingroup request
*/
MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_SUSPENDED = 11
@@ -9781,6 +9781,7 @@ enum MHD_ConnectionInfoDynamicType
* Get the TLS backend session handle.
* If plain TCP connection is used then the function returns error code
* #MHD_SC_INFO_GET_TYPE_NOT_APPLICABLE.
* The resulting union has only one valid member.
* The result is placed in @a v_tls_session member.
* @ingroup request
*/
@@ -9875,22 +9876,22 @@ union MHD_ConnInfoDynamicTlsSess
union MHD_ConnectionInfoDynamicData
{
/**
* The type for HTTP version
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_HTTP_VER query
*/
enum MHD_HTTP_ProtocolVersion v_http_ver;
/**
* The unsigned integer type
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_TIMEOUT query
*/
unsigned int v_uint;
unsigned int v_connection_timeout_uint;
/**
* The boolean type
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_SUSPENDED query
*/
enum MHD_Bool v_bool;
enum MHD_Bool v_connection_suspended_bool;
/**
* The TLS version
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_SUSPENDED query
*/
enum MHD_TlsVersion v_tls_ver;
@@ -9905,8 +9906,8 @@ union MHD_ConnectionInfoDynamicData
/**
* Obtain dynamic information about the given connection.
* This information may be changed during the lifetime of the connection.
* The wrapper macro #MHD_connection_get_info_dynamic() could be more
* convenient.
*
* The wrapper macro #MHD_connection_get_info_dynamic() may be more convenient.
*
* @param connection the connection to get information about
* @param info_type the type of information requested
+11 -10
View File
@@ -5129,14 +5129,14 @@ enum MHD_ConnectionInfoDynamicType
* automatically disconnected.
* Note: the value set is NOT the number of seconds left before automatic
* disconnection.
* The result is placed in @a v_uint member.
* The result is placed in @a v_connection_timeout_uint member.
* @ingroup request
*/
MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_TIMEOUT = 10
,
/**
* Check whether the connection is suspended.
* The result is placed in @a v_bool member.
* The result is placed in @a v_connection_suspended_bool member.
* @ingroup request
*/
MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_SUSPENDED = 11
@@ -5159,6 +5159,7 @@ enum MHD_ConnectionInfoDynamicType
* Get the TLS backend session handle.
* If plain TCP connection is used then the function returns error code
* #MHD_SC_INFO_GET_TYPE_NOT_APPLICABLE.
* The resulting union has only one valid member.
* The result is placed in @a v_tls_session member.
* @ingroup request
*/
@@ -5253,22 +5254,22 @@ union MHD_ConnInfoDynamicTlsSess
union MHD_ConnectionInfoDynamicData
{
/**
* The type for HTTP version
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_HTTP_VER query
*/
enum MHD_HTTP_ProtocolVersion v_http_ver;
/**
* The unsigned integer type
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_TIMEOUT query
*/
unsigned int v_uint;
unsigned int v_connection_timeout_uint;
/**
* The boolean type
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_SUSPENDED query
*/
enum MHD_Bool v_bool;
enum MHD_Bool v_connection_suspended_bool;
/**
* The TLS version
* The data for the #MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_SUSPENDED query
*/
enum MHD_TlsVersion v_tls_ver;
@@ -5283,8 +5284,8 @@ union MHD_ConnectionInfoDynamicData
/**
* Obtain dynamic information about the given connection.
* This information may be changed during the lifetime of the connection.
* The wrapper macro #MHD_connection_get_info_dynamic() could be more
* convenient.
*
* The wrapper macro #MHD_connection_get_info_dynamic() may be more convenient.
*
* @param connection the connection to get information about
* @param info_type the type of information requested
+5 -4
View File
@@ -107,19 +107,20 @@ MHD_connection_get_info_dynamic_sz (
output_buf->v_http_ver = connection->rq.http_ver;
return MHD_SC_OK;
case MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_TIMEOUT:
if (sizeof(output_buf->v_uint) <= output_buf_size)
if (sizeof(output_buf->v_connection_timeout_uint) <= output_buf_size)
{
const uint_fast64_t tmout_ms = connection->connection_timeout_ms;
const unsigned int tmout = (unsigned int) (tmout_ms / 1000);
mhd_assert ((1000 * ((uint_fast64_t) tmout)) == tmout_ms);
output_buf->v_uint = tmout;
output_buf->v_connection_timeout_uint = tmout;
return MHD_SC_OK;
}
return MHD_SC_INFO_GET_BUFF_TOO_SMALL;
case MHD_CONNECTION_INFO_DYNAMIC_CONNECTION_SUSPENDED:
if (sizeof(output_buf->v_bool) > output_buf_size)
if (sizeof(output_buf->v_connection_suspended_bool) > output_buf_size)
return MHD_SC_INFO_GET_BUFF_TOO_SMALL;
output_buf->v_bool = connection->suspended ? MHD_YES : MHD_NO;
output_buf->v_connection_suspended_bool =
connection->suspended ? MHD_YES : MHD_NO;
return MHD_SC_OK;
case MHD_CONNECTION_INFO_DYNAMIC_TLS_VER:
#ifdef MHD_SUPPORT_HTTPS