GNU libmicrohttpd 1.0.2
Loading...
Searching...
No Matches
misc. specialized functions

Macros

#define MHD_ICY_FLAG   ((uint32_t) (((uint32_t) 1) << 31))

Functions

_MHD_EXTERN MHD_socket MHD_quiesce_daemon (struct MHD_Daemon *daemon)
_MHD_EXTERN enum MHD_Result MHD_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen)
_MHD_EXTERN void MHD_free (void *ptr)
_MHD_EXTERN const union MHD_ConnectionInfoMHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
_MHD_EXTERN enum MHD_Result MHD_set_connection_option (struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
_MHD_EXTERN const union MHD_DaemonInfoMHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type,...)
_MHD_EXTERN const char * MHD_get_version (void)
_MHD_EXTERN uint32_t MHD_get_version_bin (void)
_MHD_EXTERN enum MHD_Result MHD_is_feature_supported (enum MHD_FEATURE feature)

Detailed Description

This group includes functions that do not fit into any particular category and that are rarely used.

Macro Definition Documentation

◆ MHD_ICY_FLAG

#define MHD_ICY_FLAG   ((uint32_t) (((uint32_t) 1) << 31))

Flag to be or-ed with MHD_HTTP status code for SHOUTcast. This will cause the response to begin with the SHOUTcast "ICY" line instead of "HTTP/1.x".

Definition at line 556 of file microhttpd.h.

Referenced by MHD_queue_response().

Function Documentation

◆ MHD_add_connection()

_MHD_EXTERN enum MHD_Result MHD_add_connection ( struct MHD_Daemon * daemon,
MHD_socket client_socket,
const struct sockaddr * addr,
socklen_t addrlen )

Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client, or if you are building a proxy.

If you use this API in conjunction with an "internal" socket polling, you must set the option MHD_USE_ITC to ensure that the freshly added connection is immediately processed by MHD.

The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards.

Parameters
daemondaemon that manages the connection
client_socketsocket to manage (MHD will expect to receive an HTTP request from this socket next).
addrIP address of the client
addrlennumber of bytes in addr
Returns
MHD_YES on success, MHD_NO if this daemon could not handle the connection (i.e. malloc() failed, etc). The socket will be closed in any case; errno is set to indicate further details about the error.

Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client, or if you are building a proxy.

If you use this API in conjunction with a internal select or a thread pool, you must set the option MHD_USE_ITC to ensure that the freshly added connection is immediately processed by MHD.

The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards.

Parameters
daemondaemon that manages the connection
client_socketsocket to manage (MHD will expect to receive an HTTP request from this socket next).
addrIP address of the client
addrlennumber of bytes in addr
Returns
MHD_YES on success, MHD_NO if this daemon could not handle the connection (i.e. malloc() failed, etc). The socket will be closed in any case; errno is set to indicate further details about the error.

Definition at line 3603 of file daemon.c.

References _, _MHD_UNKNOWN, MHD_Daemon::connection_limit, MHD_Daemon::connections, internal_add_connection(), MHD_cleanup_connections(), MHD_D_IS_THREAD_SAFE_, MHD_D_IS_USING_THREADS_, MHD_NO, MHD_socket_close_, MHD_socket_close_chk_, MHD_socket_fset_error_, MHD_socket_get_error_, MHD_socket_last_strerr_, MHD_socket_nonblocking_(), MHD_socket_noninheritable_(), MHD_USE_ITC, MHD_USE_TURBO, NULL, MHD_Daemon::options, and MHD_Daemon::sigpipe_blocked.

Here is the call graph for this function:

◆ MHD_free()

_MHD_EXTERN void MHD_free ( void * ptr)

Free the memory allocated by MHD.

If any MHD function explicitly mentions that returned pointer must be freed by this function, then no other method must be used to free the memory.

Parameters
ptrthe pointer to free.
See also
MHD_digest_auth_get_username(), MHD_basic_auth_get_username_password3()
MHD_basic_auth_get_username_password()
Note
Available since MHD_VERSION 0x00095600

Definition at line 213 of file daemon.c.

◆ MHD_get_connection_info()

_MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info ( struct MHD_Connection * connection,
enum MHD_ConnectionInfoType info_type,
... )

Obtain information about the given connection. The returned pointer is invalidated with the next call of this function or when the connection is closed.

Parameters
connectionwhat connection to get information about
info_typewhat information is desired?
...depends on info_type
Returns
NULL if this information is not available (or if the info_type is unknown)

Definition at line 7636 of file connection.c.

References MHD_Connection::addr, MHD_Connection::addr_len, MHD_ConnectionInfo::cipher_algorithm, MHD_ConnectionInfo::client_addr, MHD_ConnectionInfo::connect_fd, MHD_Connection::connection_info_dummy, MHD_ConnectionInfo::connection_timeout, MHD_Connection::connection_timeout_ms, MHD_Connection::daemon, MHD_ConnectionInfo::daemon, MHD_ConnectionInfo::header_size, MHD_Request::header_size, MHD_ConnectionInfo::http_status, mhd_assert, MHD_CONNECTION_CLOSED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_INFO_CIPHER_ALGO, MHD_CONNECTION_INFO_CLIENT_ADDRESS, MHD_CONNECTION_INFO_CONNECTION_FD, MHD_CONNECTION_INFO_CONNECTION_SUSPENDED, MHD_CONNECTION_INFO_CONNECTION_TIMEOUT, MHD_CONNECTION_INFO_DAEMON, MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT, MHD_CONNECTION_INFO_GNUTLS_SESSION, MHD_CONNECTION_INFO_HTTP_STATUS, MHD_CONNECTION_INFO_PROTOCOL, MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE, MHD_CONNECTION_INFO_SOCKET_CONTEXT, MHD_get_master(), MHD_NO, MHD_YES, NULL, MHD_ConnectionInfo::protocol, MHD_Reply::response, MHD_Reply::responseCode, MHD_Connection::rp, MHD_Connection::rq, MHD_Connection::socket_context, MHD_ConnectionInfo::socket_context, MHD_Connection::socket_fd, MHD_Connection::state, MHD_Connection::suspended, MHD_ConnectionInfo::suspended, MHD_ConnectionInfo::tls_session, and UINT_MAX.

Here is the call graph for this function:

◆ MHD_get_daemon_info()

_MHD_EXTERN const union MHD_DaemonInfo * MHD_get_daemon_info ( struct MHD_Daemon * daemon,
enum MHD_DaemonInfoType info_type,
... )

Obtain information about the given daemon. The returned pointer is invalidated with the next call of this function or when the daemon is stopped.

Parameters
daemonwhat daemon to get information about
info_typewhat information is desired?
...depends on info_type
Returns
NULL if this information is not available (or if the info_type is unknown)

Definition at line 9429 of file daemon.c.

References MHD_Daemon::connections, MHD_Daemon::daemon_info_dummy_flags, MHD_Daemon::daemon_info_dummy_listen_fd, MHD_Daemon::daemon_info_dummy_num_connections, MHD_Daemon::daemon_info_dummy_port, MHD_DaemonInfo::flags, MHD_Daemon::listen_fd, MHD_DaemonInfo::listen_fd, mhd_assert, MHD_cleanup_connections(), MHD_D_IS_THREAD_SAFE_, MHD_DAEMON_INFO_BIND_PORT, MHD_DAEMON_INFO_CURRENT_CONNECTIONS, MHD_DAEMON_INFO_EPOLL_FD, MHD_DAEMON_INFO_FLAGS, MHD_DAEMON_INFO_KEY_SIZE, MHD_DAEMON_INFO_LISTEN_FD, MHD_DAEMON_INFO_MAC_KEY_SIZE, MHD_thread_handle_ID_is_valid_handle_, MHD_USE_SELECT_INTERNALLY, NULL, MHD_DaemonInfo::num_connections, MHD_Daemon::options, MHD_Daemon::port, and MHD_DaemonInfo::port.

Here is the call graph for this function:

◆ MHD_get_version()

_MHD_EXTERN const char * MHD_get_version ( void )

Obtain the version of this library

Returns
static version string, e.g. "0.9.9"

Definition at line 9497 of file daemon.c.

References MHD_VERSION.

◆ MHD_get_version_bin()

_MHD_EXTERN uint32_t MHD_get_version_bin ( void )

Obtain the version of this library as a binary value.

Returns
version binary value, e.g. "0x00090900" (MHD_VERSION of compiled MHD binary)
Note
Available since MHD_VERSION 0x00097601

Definition at line 9528 of file daemon.c.

References MHD_VERSION.

◆ MHD_is_feature_supported()

◆ MHD_quiesce_daemon()

_MHD_EXTERN MHD_socket MHD_quiesce_daemon ( struct MHD_Daemon * daemon)

Stop accepting connections from the listening socket. Allows clients to continue processing, but stops accepting new connections. Note that the caller is responsible for closing the returned socket; however, if MHD is run using threads (anything but "external" sockets polling mode), it must not be closed until AFTER MHD_stop_daemon has been called (as it is theoretically possible that an existing thread is still using it).

Note that some thread modes require the caller to have passed MHD_USE_ITC when using this API. If this daemon is in one of those modes and this option was not given to MHD_start_daemon, this function will return MHD_INVALID_SOCKET.

Parameters
daemondaemon to stop accepting new connections for
Returns
old listen socket on success, MHD_INVALID_SOCKET if the daemon was already not listening anymore

Stop accepting connections from the listening socket. Allows clients to continue processing, but stops accepting new connections. Note that the caller is responsible for closing the returned socket; however, if MHD is run using threads (anything but external select mode), socket will be removed from existing threads with some delay and it must not be closed while it's in use. To make sure that the socket is not used anymore, call MHD_stop_daemon.

Note that some thread modes require the caller to have passed MHD_USE_ITC when using this API. If this daemon is in one of those modes and this option was not given to MHD_start_daemon, this function will return MHD_INVALID_SOCKET.

Parameters
daemondaemon to stop accepting new connections for
Returns
old listen socket on success, MHD_INVALID_SOCKET if the daemon was already not listening anymore

Definition at line 6148 of file daemon.c.

References _, MHD_Daemon::itc, MHD_Daemon::listen_fd, MHD_D_IS_USING_EPOLL_, MHD_D_IS_USING_THREADS_, MHD_INVALID_SOCKET, MHD_PANIC, MHD_USE_ITC, NULL, MHD_Daemon::options, and MHD_Daemon::was_quiesced.

◆ MHD_set_connection_option()

_MHD_EXTERN enum MHD_Result MHD_set_connection_option ( struct MHD_Connection * connection,
enum MHD_CONNECTION_OPTION option,
... )

Set a custom option for the given connection, overriding defaults.

Parameters
connectionconnection to modify
optionoption to set
...arguments to the option, depending on the option type
Returns
MHD_YES on success, MHD_NO if setting the option failed

Definition at line 7737 of file connection.c.

References _, MHD_Connection::connection_timeout_ms, MHD_Daemon::connection_timeout_ms, MHD_Connection::daemon, MHD_Connection::last_activity, MHD_Daemon::manual_timeout_head, MHD_Daemon::manual_timeout_tail, MHD_CONNECTION_OPTION_TIMEOUT, MHD_D_IS_USING_THREAD_PER_CONN_, MHD_monotonic_msec_counter(), MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_NO, MHD_YES, MHD_Daemon::normal_timeout_head, MHD_Daemon::normal_timeout_tail, PRIu64, MHD_Connection::suspended, UINT64_MAX, XDLL_insert, and XDLL_remove.

Here is the call graph for this function: