Next: , Previous: , Up: microhttpd-info   [Contents][Index]


12.2 Obtaining state information about a connection

Function: const union MHD_ConnectionInfo * MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType infoType, ...)

Obtain information about the given connection.

connection

the connection about which information is desired;

infoType

type of information that is desired

...

additional arguments about the desired information (depending on infoType)

Returns a union with the respective member (depending on infoType) set to the desired information), or NULL in case the desired information is not available or applicable.

Enumeration: MHD_ConnectionInfoType

Values of this enum are used to specify what information about a connection is desired.

MHD_CONNECTION_INFO_CIPHER_ALGO

What cipher algorithm is being used (HTTPS connections only). NULL is returned for non-HTTPS connections.

Takes no extra arguments.

MHD_CONNECTION_INFO_PROTOCOL,

Allows finding out the TLS/SSL protocol used (HTTPS connections only). NULL is returned for non-HTTPS connections.

Takes no extra arguments.

MHD_CONNECTION_INFO_CLIENT_ADDRESS

Returns information about the address of the client. Returns essentially a struct sockaddr ** (since the API returns a union MHD_ConnectionInfo * and that union contains a struct sockaddr *).

Takes no extra arguments.

MHD_CONNECTION_INFO_GNUTLS_SESSION,

Takes no extra arguments. Allows access to the underlying GNUtls session, including access to the underlying GNUtls client certificate (HTTPS connections only). Takes no extra arguments. NULL is returned for non-HTTPS connections.

Takes no extra arguments.

MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT,

Dysfunctional (never implemented, deprecated). Use MHD_CONNECTION_INFO_GNUTLS_SESSION to get the gnutls_session_t and then call gnutls_certificate_get_peers().

MHD_CONNECTION_INFO_DAEMON

Returns information about struct MHD_Daemon which manages this connection.

Takes no extra arguments.

MHD_CONNECTION_INFO_CONNECTION_FD

Returns the file descriptor (usually a TCP socket) associated with this connection (in the “connect-fd” member of the returned struct). Note that manipulating the descriptor directly can have problematic consequences (as in, break HTTP). Applications might use this access to manipulate TCP options, for example to set the “TCP-NODELAY” option for COMET-like applications. Note that MHD will set TCP-CORK after sending the HTTP header and clear it after finishing the footers automatically (if the platform supports it). As the connection callbacks are invoked in between, those might be used to set different values for TCP-CORK and TCP-NODELAY in the meantime.

Takes no extra arguments.

MHD_CONNECTION_INFO_CONNECTION_SUSPENDED

Returns pointer to an integer that is MHD_YES if the connection is currently suspended (and thus can be safely resumed) and MHD_NO otherwise.

Takes no extra arguments.

MHD_CONNECTION_INFO_SOCKET_CONTEXT

Returns the client-specific pointer to a void * that was (possibly) set during a MHD_NotifyConnectionCallback when the socket was first accepted. Note that this is NOT the same as the con_cls argument of the MHD_AccessHandlerCallback. The con_cls is fresh for each HTTP request, while the socket_context is fresh for each socket.

Takes no extra arguments.

MHD_CONNECTION_INFO_CONNECTION_TIMEOUT

Returns pointer to an unsigned int that is the current timeout used for the connection (in seconds, 0 for no timeout). Note that while suspended connections will not timeout, the timeout value returned for suspended connections will be the timeout that the connection will use after it is resumed, and thus might not be zero.

Takes no extra arguments.

MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE

Returns pointer to an size_t that represents the size of the HTTP header received from the client. Only valid after the first callback to the access handler.

Takes no extra arguments.


Next: , Previous: , Up: microhttpd-info   [Contents][Index]