libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 779abe3a66e3ea6cf6f559356a486a26f7065eec
parent 9877c2f9c686a11fde756fa937c5d4fa1ba29201
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 12 Sep 2011 08:15:12 +0000

indenting header more nicely, adding MHD_set_connection_option

Diffstat:
MChangeLog | 5+++++
Mdoc/microhttpd.texi | 183++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
Msrc/daemon/EXPORT.sym | 1+
Msrc/daemon/connection.c | 30+++++++++++++++++++++++++++++-
Msrc/daemon/daemon.c | 17+++++++----------
Msrc/daemon/internal.h | 6++++++
Msrc/include/microhttpd.h | 215++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
7 files changed, 301 insertions(+), 156 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 12 10:05:36 CEST 2011 + Added new function to allow setting of a custom timeout value + for an individual connection (the MHD_set_connection_option is + more generic, but this is currently the only use). -CG + Sat Sep 10 07:30:12 CEST 2011 Documenting that MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT is not implemented and will not be implemented, and what to use instead. -CG diff --git a/doc/microhttpd.texi b/doc/microhttpd.texi @@ -113,7 +113,7 @@ GNU libmicrohttpd is a GNU package. * microhttpd-responses:: Building responses to requests. * microhttpd-dauth:: Utilizing Authentication. * microhttpd-post:: Adding a @code{POST} processor. -* microhttpd-info:: Obtaining status information. +* microhttpd-info:: Obtaining and modifying status information. Appendices @@ -706,73 +706,6 @@ own private copy of the data for processing. @end deftp -@deftp {Enumeration} MHD_ConnectionInfoType -Values of this enum are used to specify what information about a -connection is desired. - -@table @code - -@item MHD_CONNECTION_INFO_CIPHER_ALGO -What cipher algorithm is being used (HTTPS connections only). -Takes no extra arguments. -NULL is returned for non-HTTPS connections. - -@item MHD_CONNECTION_INFO_PROTOCOL, -Takes no extra arguments. Allows finding out the TLS/SSL protocol used -(HTTPS connections only). -NULL is returned for non-HTTPS connections. - -@item MHD_CONNECTION_INFO_CLIENT_ADDRESS -Returns information about the address of the client. Returns -essentially a @code{struct sockaddr **} (since the API returns -a @code{union MHD_ConnectionInfo *} and that union contains -a @code{struct sockaddr *}). - -@item 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. - -@item MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT, -Dysfunctional (never implemented, deprecated). Use -MHD_CONNECTION_INFO_GNUTLS_SESSION to get the @code{gnutls_session_t} -and then call @code{gnutls_certificate_get_peers()}. - -@item MHD_CONNECTION_INFO_DAEMON -Returns information about @code{struct MHD_Daemon} which manages -this connection. - -@end table -@end deftp - - - - -@deftp {Enumeration} MHD_DaemonInfoType -Values of this enum are used to specify what -information about a daemon is desired. -@table @code -@item MHD_DAEMON_INFO_KEY_SIZE -Request information about the key size for a particular cipher -algorithm. The cipher algorithm should be passed as an extra argument -(of type 'enum MHD_GNUTLS_CipherAlgorithm'). - -@item MHD_DAEMON_INFO_MAC_KEY_SIZE -Request information about the key size for a particular cipher -algorithm. The cipher algorithm should be passed as an extra argument -(of type 'enum MHD_GNUTLS_HashAlgorithm'). - -@item MHD_DAEMON_INFO_LISTEN_FD -@cindex listen -Request the file-descriptor number that MHD is using to listen to the -server socket. This can be useful if no port -was specified and a client needs to learn what port -is actually being used by MHD. -No extra arguments should be passed. - -@end table -@end deftp @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1394,8 +1327,6 @@ Return @mynull{} on error (i.e. invalid arguments, out of memory). @deftypefun {struct MHD_Response *} MHD_create_response_from_fd (uint64_t size, int fd) Create a response object. The response object can be extended with header information and then it can be used any number of times. -Function is deprecated, use @code{MHD_create_response_from_fd_at_offset} -instead (with an offset of zero). @table @var @item size @@ -1942,12 +1873,13 @@ of this function. @c ------------------------------------------------------------ @node microhttpd-info -@chapter Obtaining status information. +@chapter Obtaining and modifying status information. @menu * microhttpd-info daemon:: State information about an MHD daemon * microhttpd-info conn:: State information about a connection +* microhttpd-option conn:: Modify per-connection options @end menu @@ -1977,6 +1909,34 @@ in case the desired information is not available or applicable. @end deftypefun + +@deftp {Enumeration} MHD_DaemonInfoType +Values of this enum are used to specify what +information about a daemon is desired. +@table @code +@item MHD_DAEMON_INFO_KEY_SIZE +Request information about the key size for a particular cipher +algorithm. The cipher algorithm should be passed as an extra argument +(of type 'enum MHD_GNUTLS_CipherAlgorithm'). + +@item MHD_DAEMON_INFO_MAC_KEY_SIZE +Request information about the key size for a particular cipher +algorithm. The cipher algorithm should be passed as an extra argument +(of type 'enum MHD_GNUTLS_HashAlgorithm'). + +@item MHD_DAEMON_INFO_LISTEN_FD +@cindex listen +Request the file-descriptor number that MHD is using to listen to the +server socket. This can be useful if no port +was specified and a client needs to learn what port +is actually being used by MHD. +No extra arguments should be passed. + +@end table +@end deftp + + + @c ------------------------------------------------------------ @node microhttpd-info conn @section Obtaining state information about a connection @@ -2003,6 +1963,87 @@ in case the desired information is not available or applicable. @end deftypefun +@deftp {Enumeration} MHD_ConnectionInfoType +Values of this enum are used to specify what information about a +connection is desired. + +@table @code + +@item MHD_CONNECTION_INFO_CIPHER_ALGO +What cipher algorithm is being used (HTTPS connections only). +Takes no extra arguments. +NULL is returned for non-HTTPS connections. + +@item MHD_CONNECTION_INFO_PROTOCOL, +Takes no extra arguments. Allows finding out the TLS/SSL protocol used +(HTTPS connections only). +NULL is returned for non-HTTPS connections. + +@item MHD_CONNECTION_INFO_CLIENT_ADDRESS +Returns information about the address of the client. Returns +essentially a @code{struct sockaddr **} (since the API returns +a @code{union MHD_ConnectionInfo *} and that union contains +a @code{struct sockaddr *}). + +@item 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. + +@item MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT, +Dysfunctional (never implemented, deprecated). Use +MHD_CONNECTION_INFO_GNUTLS_SESSION to get the @code{gnutls_session_t} +and then call @code{gnutls_certificate_get_peers()}. + +@item MHD_CONNECTION_INFO_DAEMON +Returns information about @code{struct MHD_Daemon} which manages +this connection. + +@end table +@end deftp + + + +@c ------------------------------------------------------------ +@node microhttpd-option conn +@section Setting custom options for an individual connection +@cindex timeout + + + +@deftypefun {int} MHD_set_connection_option (struct MHD_Connection *daemon, enum MHD_CONNECTION_OPTION option, ...) +Set a custom option for the given connection. + +@table @var +@item connection +the connection for which an option should be set or modified; + +@item option +option to set + +@item ... +additional arguments for the option (depending on option) +@end table + +Returns @code{MHD_YES} on success, @code{MHD_NO} for errors +(i.e. option argument invalid or option unknown). +@end deftypefun + + +@deftp {Enumeration} MHD_CONNECTION_OPTION +Values of this enum are used to specify which option for a +connection should be changed. + +@table @code + +@item MHD_CONNECTION_OPTION_TIMEOUT +Set a custom timeout for the given connection. Specified +as the number of seconds, given as an @code{unsigned int}. Use +zero for no timeout. + +@end table +@end deftp @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/src/daemon/EXPORT.sym b/src/daemon/EXPORT.sym @@ -32,3 +32,4 @@ MHD_queue_auth_fail_response MHD_basic_auth_get_username_password MHD_queue_basic_auth_fail_response MHD_add_connection +MHD_set_connection_option diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -2293,7 +2293,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) } break; } - timeout = connection->daemon->connection_timeout; + timeout = connection->connection_timeout; if ( (timeout != 0) && (timeout <= (time (NULL) - connection->last_activity)) ) { @@ -2354,4 +2354,32 @@ MHD_get_connection_info (struct MHD_Connection *connection, } +/** + * Set a custom option for the given connection, overriding defaults. + * + * @param connection connection to modify + * @param option option to set + * @param ... arguments to the option, depending on the option type + * @return MHD_YES on success, MHD_NO if setting the option failed + */ +int +MHD_set_connection_option (struct MHD_Connection *connection, + enum MHD_CONNECTION_OPTION option, + ...) +{ + va_list ap; + + switch (option) + { + case MHD_CONNECTION_OPTION_TIMEOUT: + va_start (ap, option); + connection->connection_timeout = va_arg (ap, unsigned int); + va_end (ap); + return MHD_YES; + default: + return MHD_NO; + } +} + + /* end of connection.c */ diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -953,6 +953,7 @@ MHD_add_connection (struct MHD_Daemon *daemon, return MHD_NO; } memset (connection, 0, sizeof (struct MHD_Connection)); + connection->connection_timeout = daemon->connection_timeout; connection->pool = NULL; connection->addr = malloc (addrlen); if (connection->addr == NULL) @@ -1222,7 +1223,6 @@ MHD_get_timeout (struct MHD_Daemon *daemon, time_t earliest_deadline; time_t now; struct MHD_Connection *pos; - unsigned int dto; if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { @@ -1231,26 +1231,23 @@ MHD_get_timeout (struct MHD_Daemon *daemon, #endif return MHD_NO; } - dto = daemon->connection_timeout; - if (0 == dto) - return MHD_NO; pos = daemon->connections_head; if (pos == NULL) return MHD_NO; /* no connections */ - now = time (NULL); - /* start with conservative estimate */ - earliest_deadline = now + dto + 1; + earliest_deadline = pos->last_activity + pos->connection_timeout; + pos = pos->next; while (pos != NULL) { - if (earliest_deadline > pos->last_activity + dto) - earliest_deadline = pos->last_activity + dto; + if (earliest_deadline > pos->last_activity + pos->connection_timeout) + earliest_deadline = pos->last_activity + pos->connection_timeout; #if HTTPS_SUPPORT if ( (0 != (daemon->options & MHD_USE_SSL)) && (0 != gnutls_record_check_pending (pos->tls_session)) ) - earliest_deadline = now; + earliest_deadline = 0; #endif pos = pos->next; } + now = time (NULL); if (earliest_deadline < now) *timeout = 0; else diff --git a/src/daemon/internal.h b/src/daemon/internal.h @@ -608,6 +608,12 @@ struct MHD_Connection time_t last_activity; /** + * After how many seconds of inactivity should + * this connection time out? Zero for no timeout. + */ + unsigned int connection_timeout; + + /** * Did we ever call the "default_handler" on this connection? * (this flag will determine if we call the 'notify_completed' * handler when the connection closes down). diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -106,7 +106,7 @@ extern "C" /** * Current version of the library. */ -#define MHD_VERSION 0x00090D01 +#define MHD_VERSION 0x00090E00 /** * MHD-internal return code for "YES". @@ -368,9 +368,9 @@ enum MHD_FLAG MHD_USE_POLL = 64 }; + /** - * MHD options. Passed in the varargs portion - * of MHD_start_daemon. + * MHD options. Passed in the varargs portion of MHD_start_daemon. */ enum MHD_OPTION { @@ -662,6 +662,7 @@ enum MHD_ValueKind MHD_FOOTER_KIND = 16 }; + /** * The MHD_RequestTerminationCode specifies reasons * why a request has been terminated (or completed). @@ -743,6 +744,7 @@ enum MHD_ConnectionInfoType }; + /** * Values of this enum are used to specify what * information about a deamon is desired. @@ -773,7 +775,6 @@ enum MHD_DaemonInfoType }; - /** * Handle for the daemon (listening on a socket for HTTP traffic). */ @@ -797,6 +798,7 @@ struct MHD_Response; */ struct MHD_PostProcessor; + /** * Callback for serious error condition. The default action is to abort(). * @param cls user specified value @@ -804,10 +806,11 @@ struct MHD_PostProcessor; * @param line where the error occured * @param reason error detail, may be NULL */ -typedef void (*MHD_PanicCallback) (void *cls, - const char *file, - unsigned int line, - const char *reason); +typedef + void (*MHD_PanicCallback) (void *cls, + const char *file, + unsigned int line, + const char *reason); /** * Allow or deny a client to connect. @@ -821,6 +824,7 @@ typedef int const struct sockaddr * addr, socklen_t addrlen); + /** * A client has requested the given url using the given method ("GET", * "PUT", "DELETE", "POST", etc). The callback must call MHS @@ -866,6 +870,7 @@ typedef int size_t *upload_data_size, void **con_cls); + /** * Signature of the callback used by MHD to notify the * application about completed requests. @@ -883,6 +888,7 @@ typedef void void **con_cls, enum MHD_RequestTerminationCode toe); + /** * Iterator over key-value pairs. This iterator * can be used to iterate over all of the cookies, @@ -898,6 +904,7 @@ typedef int enum MHD_ValueKind kind, const char *key, const char *value); + /** * Callback used by libmicrohttpd in order to obtain content. The * callback is to copy at most "max" bytes of content into "buf". The @@ -951,13 +958,16 @@ typedef ssize_t char *buf, size_t max); + /** * This method is called by libmicrohttpd if we * are done with a content reader. It should * be used to free resources associated with the * content reader. */ -typedef void (*MHD_ContentReaderFreeCallback) (void *cls); +typedef void + (*MHD_ContentReaderFreeCallback) (void *cls); + /** * Iterator over key-value pairs where the value @@ -985,7 +995,9 @@ typedef int const char *filename, const char *content_type, const char *transfer_encoding, - const char *data, uint64_t off, size_t size); + const char *data, + uint64_t off, + size_t size); /* **************** Daemon handling functions ***************** */ @@ -1005,12 +1017,13 @@ typedef int * terminated with MHD_OPTION_END). * @return NULL on error, handle to daemon on success */ -struct MHD_Daemon *MHD_start_daemon_va (unsigned int options, - uint16_t port, - MHD_AcceptPolicyCallback apc, - void *apc_cls, - MHD_AccessHandlerCallback dh, - void *dh_cls, va_list ap); +struct MHD_Daemon * +MHD_start_daemon_va (unsigned int options, + uint16_t port, + MHD_AcceptPolicyCallback apc, void *apc_cls, + MHD_AccessHandlerCallback dh, void *dh_cls, + va_list ap); + /** * Start a webserver on the given port. Variadic version of @@ -1027,19 +1040,21 @@ struct MHD_Daemon *MHD_start_daemon_va (unsigned int options, * @param dh_cls extra argument to dh * @return NULL on error, handle to daemon on success */ -struct MHD_Daemon *MHD_start_daemon (unsigned int flags, - uint16_t port, - MHD_AcceptPolicyCallback apc, - void *apc_cls, - MHD_AccessHandlerCallback dh, - void *dh_cls, ...); +struct MHD_Daemon * +MHD_start_daemon (unsigned int flags, + uint16_t port, + MHD_AcceptPolicyCallback apc, void *apc_cls, + MHD_AccessHandlerCallback dh, void *dh_cls, + ...); + /** * Shutdown an http daemon. * * @param daemon daemon to stop */ -void MHD_stop_daemon (struct MHD_Daemon *daemon); +void +MHD_stop_daemon (struct MHD_Daemon *daemon); /** @@ -1063,10 +1078,11 @@ void MHD_stop_daemon (struct MHD_Daemon *daemon); * not handle the connection (i.e. malloc failed, etc). * The socket will be closed in any case. */ -int MHD_add_connection (struct MHD_Daemon *daemon, - int client_socket, - const struct sockaddr *addr, - socklen_t addrlen); +int +MHD_add_connection (struct MHD_Daemon *daemon, + int client_socket, + const struct sockaddr *addr, + socklen_t addrlen); /** @@ -1084,8 +1100,11 @@ int MHD_add_connection (struct MHD_Daemon *daemon, */ int MHD_get_fdset (struct MHD_Daemon *daemon, - fd_set * read_fd_set, - fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd); + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *except_fd_set, + int *max_fd); + /** * Obtain timeout value for select for this daemon (only needed if @@ -1115,7 +1134,8 @@ int MHD_get_timeout (struct MHD_Daemon *daemon, * daemon was not started with the right * options for this call. */ -int MHD_run (struct MHD_Daemon *daemon); +int +MHD_run (struct MHD_Daemon *daemon); /* **************** Connection handling functions ***************** */ @@ -1135,6 +1155,7 @@ MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls); + /** * This function can be used to add an entry to * the HTTP headers of a connection (so that the @@ -1167,7 +1188,9 @@ MHD_get_connection_values (struct MHD_Connection *connection, int MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, - const char *key, const char *value); + const char *key, + const char *value); + /** * Sets the global error handler to a different implementation. "cb" @@ -1184,7 +1207,9 @@ MHD_set_connection_value (struct MHD_Connection *connection, * @param cb new error handler * @param cls passed to error handler */ -void MHD_set_panic_func (MHD_PanicCallback cb, void *cls); +void +MHD_set_panic_func (MHD_PanicCallback cb, void *cls); + /** * Get a particular header value. If multiple @@ -1195,9 +1220,11 @@ void MHD_set_panic_func (MHD_PanicCallback cb, void *cls); * @param key the header to look for * @return NULL if no such item was found */ -const char *MHD_lookup_connection_value (struct MHD_Connection *connection, - enum MHD_ValueKind kind, - const char *key); +const char * +MHD_lookup_connection_value (struct MHD_Connection *connection, + enum MHD_ValueKind kind, + const char *key); + /** * Queue a response to be transmitted to the client (as soon as @@ -1211,7 +1238,8 @@ const char *MHD_lookup_connection_value (struct MHD_Connection *connection, */ int MHD_queue_response (struct MHD_Connection *connection, - unsigned int status_code, struct MHD_Response *response); + unsigned int status_code, + struct MHD_Response *response); /* **************** Response manipulation functions ***************** */ @@ -1231,12 +1259,11 @@ MHD_queue_response (struct MHD_Connection *connection, * @param crfc callback to call to free crc_cls resources * @return NULL on error (i.e. invalid arguments, out of memory) */ -struct MHD_Response *MHD_create_response_from_callback (uint64_t size, - size_t block_size, - MHD_ContentReaderCallback - crc, void *crc_cls, - MHD_ContentReaderFreeCallback - crfc); +struct MHD_Response * +MHD_create_response_from_callback (uint64_t size, + size_t block_size, + MHD_ContentReaderCallback crc, void *crc_cls, + MHD_ContentReaderFreeCallback crfc); /** @@ -1252,10 +1279,11 @@ struct MHD_Response *MHD_create_response_from_callback (uint64_t size, * @return NULL on error (i.e. invalid arguments, out of memory) * @deprecated use MHD_create_response_from_buffer instead */ -struct MHD_Response *MHD_create_response_from_data (size_t size, - void *data, - int must_free, - int must_copy); +struct MHD_Response * +MHD_create_response_from_data (size_t size, + void *data, + int must_free, + int must_copy); /** @@ -1313,10 +1341,10 @@ MHD_create_response_from_buffer (size_t size, * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @return NULL on error (i.e. invalid arguments, out of memory) - * @deprecated use MHD_create_response_from_fd_at_offset instead */ -struct MHD_Response *MHD_create_response_from_fd (size_t size, - int fd); +struct MHD_Response * +MHD_create_response_from_fd (size_t size, + int fd); /** @@ -1327,12 +1355,17 @@ struct MHD_Response *MHD_create_response_from_fd (size_t size, * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode - * @param off offset to start reading from in the file + * @param off offset to start reading from in the file; + * Be careful! 'off_t' may have been compiled to be a + * 64-bit variable for MHD, in which case your application + * also has to be compiled using the same options! Read + * the MHD manual for more details. * @return NULL on error (i.e. invalid arguments, out of memory) */ -struct MHD_Response *MHD_create_response_from_fd_at_offset (size_t size, - int fd, - off_t offset); +struct MHD_Response * +MHD_create_response_from_fd_at_offset (size_t size, + int fd, + off_t offset); /** @@ -1345,6 +1378,7 @@ struct MHD_Response *MHD_create_response_from_fd_at_offset (size_t size, */ void MHD_destroy_response (struct MHD_Response *response); + /** * Add a header line to the response. * @@ -1432,13 +1466,12 @@ const char *MHD_get_response_header (struct MHD_Response *response, * Must NOT be NULL. * @param cls first argument to ikvi * @return NULL on error (out of memory, unsupported encoding), - otherwise a PP handle + * otherwise a PP handle */ -struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection - *connection, - size_t buffer_size, - MHD_PostDataIterator - iter, void *cls); +struct MHD_PostProcessor * +MHD_create_post_processor (struct MHD_Connection *connection, + size_t buffer_size, + MHD_PostDataIterator iter, void *cls); /** * Parse and process POST data. @@ -1467,7 +1500,8 @@ MHD_post_process (struct MHD_PostProcessor *pp, * problems; it is common to ignore the return * value of this function */ -int MHD_destroy_post_processor (struct MHD_PostProcessor *pp); +int +MHD_destroy_post_processor (struct MHD_PostProcessor *pp); /* ********************* Digest Authentication functions *************** */ @@ -1541,8 +1575,8 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection, * to the username if found */ char * -MHD_basic_auth_get_username_password(struct MHD_Connection *connection, - char** password); +MHD_basic_auth_get_username_password (struct MHD_Connection *connection, + char** password); /** * Queues a response to request basic authentication from the client @@ -1552,9 +1586,9 @@ MHD_basic_auth_get_username_password(struct MHD_Connection *connection, * @return MHD_YES on success, MHD_NO otherwise */ int -MHD_queue_basic_auth_fail_response(struct MHD_Connection *connection, - const char *realm, - struct MHD_Response *response); +MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, + const char *realm, + struct MHD_Response *response); /* ********************** generic query functions ********************** */ @@ -1605,14 +1639,44 @@ union MHD_ConnectionInfo * @return NULL if this information is not available * (or if the infoType is unknown) */ -const union MHD_ConnectionInfo *MHD_get_connection_info (struct MHD_Connection - *connection, - enum - MHD_ConnectionInfoType - infoType, ...); +const union MHD_ConnectionInfo * +MHD_get_connection_info (struct MHD_Connection *connection, + enum MHD_ConnectionInfoType infoType, + ...); /** + * MHD connection options. Given to 'MHD_set_connection_option' to + * set custom options for a particular connection. + */ +enum MHD_CONNECTION_OPTION +{ + + /** + * Set a custom timeout for the given connection. Specified + * as the number of seconds, given as an 'unsigned int'. Use + * zero for no timeout. + */ + MHD_CONNECTION_OPTION_TIMEOUT + +}; + + +/** + * Set a custom option for the given connection, overriding defaults. + * + * @param connection connection to modify + * @param option option to set + * @param ... arguments to the option, depending on the option type + * @return MHD_YES on success, MHD_NO if setting the option failed + */ +int +MHD_set_connection_option (struct MHD_Connection *connection, + enum MHD_CONNECTION_OPTION option, + ...); + + +/** * Information about an MHD daemon. */ union MHD_DaemonInfo @@ -1643,16 +1707,19 @@ union MHD_DaemonInfo * @return NULL if this information is not available * (or if the infoType is unknown) */ -const union MHD_DaemonInfo *MHD_get_daemon_info (struct MHD_Daemon *daemon, - enum MHD_DaemonInfoType - infoType, ...); +const union MHD_DaemonInfo * +MHD_get_daemon_info (struct MHD_Daemon *daemon, + enum MHD_DaemonInfoType infoType, + ...); + /** * Obtain the version of this library * * @return static version string, e.g. "0.9.9" */ -const char* MHD_get_version(void); +const char* +MHD_get_version (void); #if 0 /* keep Emacsens' auto-indent happy */ {