mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
add response option generation;
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
microhttpd2_inline_documentation.h.in
|
||||
microhttpd2_generated_daemon_options.h
|
||||
microhttpd2_inline_daemon_documentation.h.in
|
||||
microhttpd2_inline_response_documentation.h.in
|
||||
d_options.json
|
||||
daemon-options-generator
|
||||
microhttpd2.h
|
||||
options-generator
|
||||
r_options.json
|
||||
|
||||
+20
-11
@@ -1,26 +1,33 @@
|
||||
# This Makefile.am is in the public domain
|
||||
SUBDIRS = .
|
||||
|
||||
d_options.json: d_options.tmpl d_options.rec
|
||||
recfmt -f d_options.tmpl < d_options.rec | sed -e "s/,*]/]/g" -e "s/\(,\"\"\)*]/]/" -e "s/\[\"\"\]/\[\]/" -e '0,/./i{' -e '$$a"end":""}' -e 's/\"\"/null/' | gawk -v RS='"' 'NR % 2 == 0 { gsub(/\n/, "\\n") } { printf("%s%s", $$0, RT) }' | jq 'del(..|nulls)' > d_options.json
|
||||
d_options.json: options.tmpl d_options.rec
|
||||
recfmt -f options.tmpl < d_options.rec | sed -e "s/,*]/]/g" -e "s/\(,\"\"\)*]/]/" -e "s/\[\"\"\]/\[\]/" -e '0,/./i{' -e '$$a"end":""}' -e 's/\"\"/null/' | gawk -v RS='"' 'NR % 2 == 0 { gsub(/\n/, "\\n") } { printf("%s%s", $$0, RT) }' | jq 'del(..|nulls)' > d_options.json
|
||||
|
||||
microhttpd2_generated_daemon_options.h: d_options.json daemon-options-generator
|
||||
rm -f $@
|
||||
./daemon-options-generator > microhttpd2_generated_daemon_options.h
|
||||
r_options.json: options.tmpl r_options.rec
|
||||
recfmt -f options.tmpl < r_options.rec | sed -e "s/,*]/]/g" -e "s/\(,\"\"\)*]/]/" -e "s/\[\"\"\]/\[\]/" -e '0,/./i{' -e '$$a"end":""}' -e 's/\"\"/null/' | gawk -v RS='"' 'NR % 2 == 0 { gsub(/\n/, "\\n") } { printf("%s%s", $$0, RT) }' | jq 'del(..|nulls)' > r_options.json
|
||||
|
||||
microhttpd2_inline_daemon_documentation.h.in microhttpd2_generated_daemon_options.h: d_options.json options-generator
|
||||
rm -f microhttpd2_inline_daemon_documentation.h.in microhttpd2_generated_daemon_options.h
|
||||
./options-generator daemon > microhttpd2_generated_daemon_options.h
|
||||
chmod -w $@
|
||||
microhttpd2_inline_response_documentation.h.in microhttpd2_generated_response_options.h: r_options.json options-generator
|
||||
rm -f microhttpd2_inline_response_documentation.h.in microhttpd2_generated_response_options.h
|
||||
./options-generator response > microhttpd2_generated_response_options.h
|
||||
chmod -w $@
|
||||
|
||||
microhttpd2.h: microhttpd2_preamble.h.in microhttpd2_inline_documentation.h.in microhttpd2_main.h.in microhttpd2_postamble.h.in
|
||||
microhttpd2.h: microhttpd2_preamble.h.in microhttpd2_inline_daemon_documentation.h.in microhttpd2_inline_response_documentation.h.in microhttpd2_main.h.in microhttpd2_postamble.h.in
|
||||
rm -f $@
|
||||
cat $^ >$@
|
||||
chmod -w $@
|
||||
|
||||
# TODO: make conditional on 'libjansson' being available!
|
||||
noinst_PROGRAMS = \
|
||||
daemon-options-generator
|
||||
options-generator
|
||||
|
||||
daemon_options_generator_SOURCES = \
|
||||
daemon-options-generator.c
|
||||
daemon_options_generator_LDADD = \
|
||||
options_generator_SOURCES = \
|
||||
options-generator.c
|
||||
options_generator_LDADD = \
|
||||
-ljansson
|
||||
|
||||
mhd2includedir = $(includedir)/mhd2
|
||||
@@ -30,6 +37,7 @@ include_HEADERS = \
|
||||
mhd2include_HEADERS = \
|
||||
microhttpd2.h \
|
||||
microhttpd2_generated_daemon_options.h \
|
||||
microhttpd2_generated_response_options.h \
|
||||
microhttpd2_portability.h
|
||||
|
||||
noinst_HEADERS = \
|
||||
@@ -46,6 +54,7 @@ EXTRA_DIST = \
|
||||
mhd_options.h \
|
||||
d_options.tmpl \
|
||||
d_options.rec \
|
||||
microhttpd2_generated_daemon_options2.h \
|
||||
microhttpd2_generated_daemon_options.h \
|
||||
microhttpd2_generated_response_options.h \
|
||||
microhttpd2_portability.h \
|
||||
microhttpd2.h
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2367 @@
|
||||
/**
|
||||
* The options (parameters) for MHD daemon
|
||||
*/
|
||||
enum MHD_FIXED_ENUM_APP_SET_ MHD_DaemonOption
|
||||
{ /**
|
||||
* Not a real option.
|
||||
* Should not be used directly.
|
||||
* This value indicates the end of the list of the options.
|
||||
*/
|
||||
MHD_D_O_END = 0
|
||||
,
|
||||
|
||||
/**
|
||||
* Set MHD work (threading and polling) mode.
|
||||
* Consider use of #MHD_D_OPTION_WM_EXTERNAL_PERIODIC(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_D_OPTION_WM_EXTERNAL_SINGLE_FD_WATCH(), #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION() instead of direct use of this parameter.
|
||||
*/
|
||||
MHD_D_O_WORK_MODE = 40
|
||||
,
|
||||
|
||||
/**
|
||||
* Select a sockets watch system call used for internal polling.
|
||||
*/
|
||||
MHD_D_O_POLL_SYSCALL = 41
|
||||
,
|
||||
|
||||
/**
|
||||
* Set a callback to use for logging
|
||||
*/
|
||||
MHD_D_O_LOG_CALLBACK = 60
|
||||
,
|
||||
|
||||
/**
|
||||
* Bind to the given TCP port and address family.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_SA() or #MHD_D_OPTION_LISTEN_SOCKET().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
*/
|
||||
MHD_D_O_BIND_PORT = 80
|
||||
,
|
||||
|
||||
/**
|
||||
* Bind to the given socket address.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_LISTEN_SOCKET().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
*/
|
||||
MHD_D_O_BIND_SA = 81
|
||||
,
|
||||
|
||||
/**
|
||||
* Accept connections from the given socket. Socket
|
||||
* must be a TCP or UNIX domain (SOCK_STREAM) socket.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
*/
|
||||
MHD_D_O_LISTEN_SOCKET = 82
|
||||
,
|
||||
|
||||
/**
|
||||
* Select mode of reusing address:port listen address.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
*/
|
||||
MHD_D_O_LISTEN_ADDR_REUSE = 100
|
||||
,
|
||||
|
||||
/**
|
||||
* Configure TCP_FASTOPEN option, including setting a
|
||||
* custom @a queue_length.
|
||||
*
|
||||
Note that having a larger queue size can cause resource exhaustion
|
||||
* attack as the TCP stack has to now allocate resources for the SYN
|
||||
* packet along with its DATA.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
*/
|
||||
MHD_D_O_TCP_FASTOPEN = 101
|
||||
,
|
||||
|
||||
/**
|
||||
* Use the given backlog for the listen() call.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
*/
|
||||
MHD_D_O_LISTEN_BACKLOG = 102
|
||||
,
|
||||
|
||||
/**
|
||||
* Inform that SIGPIPE is suppressed or handled by application.
|
||||
* If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`.
|
||||
* Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically.
|
||||
*/
|
||||
MHD_D_O_SIGPIPE_SUPPRESSED = 103
|
||||
,
|
||||
|
||||
/**
|
||||
* Enable TLS (HTTPS) and select TLS backend
|
||||
*/
|
||||
MHD_D_O_TLS = 120
|
||||
,
|
||||
|
||||
/**
|
||||
* Provide TLS key and certificate data in-memory.
|
||||
* Works only if TLS mode is enabled.
|
||||
*/
|
||||
MHD_D_O_TLS_KEY_CERT = 121
|
||||
,
|
||||
|
||||
/**
|
||||
* Provide the certificate of the certificate authority (CA) to be used by the MHD daemon for client authentication.
|
||||
* Works only if TLS mode is enabled.
|
||||
*/
|
||||
MHD_D_O_TLS_CLIENT_CA = 122
|
||||
,
|
||||
|
||||
/**
|
||||
* Configure PSK to use for the TLS key exchange.
|
||||
*/
|
||||
MHD_D_O_TLS_PSK_CALLBACK = 130
|
||||
,
|
||||
|
||||
/**
|
||||
* Control ALPN for TLS connection.
|
||||
* Silently ignored for non-TLS.
|
||||
* By default ALPN is automatically used for TLS connections.
|
||||
*/
|
||||
MHD_D_O_NO_ALPN = 140
|
||||
,
|
||||
|
||||
/**
|
||||
* Specify inactivity timeout for connection.
|
||||
* When no activity for specified time on connection, it is closed automatically.
|
||||
* Use zero for no timeout, which is also the (unsafe!) default.
|
||||
*/
|
||||
MHD_D_O_DEFAULT_TIMEOUT = 160
|
||||
,
|
||||
|
||||
/**
|
||||
* Maximum number of (concurrent) network connections served by daemon
|
||||
*/
|
||||
MHD_D_O_GLOBAL_CONNECTION_LIMIT = 161
|
||||
,
|
||||
|
||||
/**
|
||||
* Limit on the number of (concurrent) network connections made to the server from the same IP address.
|
||||
* Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected.
|
||||
*/
|
||||
MHD_D_O_PER_IP_LIMIT = 162
|
||||
,
|
||||
|
||||
/**
|
||||
* Set a policy callback that accepts/rejects connections based on the client's IP address. The callbeck function will be called before servicing any new incoming connection.
|
||||
*/
|
||||
MHD_D_O_ACCEPT_POLICY = 163
|
||||
,
|
||||
|
||||
/**
|
||||
* Set how strictly MHD will enforce the HTTP protocol.
|
||||
*/
|
||||
MHD_D_O_PROTOCOL_STRICT_LEVEL = 200
|
||||
,
|
||||
|
||||
/**
|
||||
* Set a callback to be called first for every request when the request line is received (before any parsing of the header).
|
||||
* This callback is the only way to get raw (unmodified) request URI as URI is parsed and modified by MHD in-place.
|
||||
* Mandatory URI modification may apply before this call, like binary zero replacement, as required by RFCs.
|
||||
*/
|
||||
MHD_D_O_EARLY_URI_LOGGER = 201
|
||||
,
|
||||
|
||||
/**
|
||||
* Disable converting plus ('+') character to space in GET parameters (URI part after '?').
|
||||
* Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details.
|
||||
* By default plus is converted to space in the query part of URI.
|
||||
*/
|
||||
MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE = 202
|
||||
,
|
||||
|
||||
/**
|
||||
* Suppresse use of 'Date:' header.
|
||||
* According to RFC should be suppressed only if the system has no RTC.
|
||||
* The 'Date:' is not suppressed (the header is enabled) by default.
|
||||
*/
|
||||
MHD_D_O_SUPPRESS_DATE_HEADER = 240
|
||||
,
|
||||
|
||||
/**
|
||||
* Use SHOUTcast for responses.
|
||||
* This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'.
|
||||
*/
|
||||
MHD_D_O_ENABLE_SHOUTCAST = 241
|
||||
,
|
||||
|
||||
/**
|
||||
* Maximum memory size per connection.
|
||||
* Default is 32kb.
|
||||
* Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.
|
||||
* The size should be large enough to fit all request headers (together with internal parsing information).
|
||||
*/
|
||||
MHD_D_O_CONN_MEMORY_LIMIT = 280
|
||||
,
|
||||
|
||||
/**
|
||||
* The size of the shared memory pool for accamulated upload processing.
|
||||
* The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application.
|
||||
* Default is 8Mb.
|
||||
* Can be set to zero to disable share pool.
|
||||
*/
|
||||
MHD_D_O_LARGE_POOL_SIZE = 281
|
||||
,
|
||||
|
||||
/**
|
||||
* Desired size of the stack for the threads started by MHD.
|
||||
* Use 0 for system default, which is also MHD default.
|
||||
* Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
*/
|
||||
MHD_D_O_STACK_SIZE = 282
|
||||
,
|
||||
|
||||
/**
|
||||
* The the maximum FD value.
|
||||
* The limit is applied to all sockets used by MHD.
|
||||
* If listen socket FD is equal or higher that specified value, the daemon fail to start.
|
||||
* If new connection FD is equal or higher that specified value, the connection is rejected.
|
||||
* Useful if application uses select() for polling the sockets, system FD_SETSIZE is good value for this option in such case.
|
||||
* Does not work with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* Does not work on W32 (WinSock sockets).
|
||||
*/
|
||||
MHD_D_O_FD_NUMBER_LIMIT = 283
|
||||
,
|
||||
|
||||
/**
|
||||
* Enable `turbo`.
|
||||
* Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
|
||||
* Most effects only happen with internal threads with epoll.
|
||||
* The 'turbo' mode is not enabled (mode is disabled) by default.
|
||||
*/
|
||||
MHD_D_O_TURBO = 320
|
||||
,
|
||||
|
||||
/**
|
||||
* Disable some internal thread safety.
|
||||
* Indicates that MHD daemon will be used by application in single-threaded mode only. When this flag is set then application must call any MHD function only within a single thread.
|
||||
* This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment.
|
||||
* Not compatible with any internal threads modes.
|
||||
* If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory.
|
||||
* Thread safety is not disabled (safety is enabled) by default.
|
||||
*/
|
||||
MHD_D_O_DISABLE_THREAD_SAFETY = 321
|
||||
,
|
||||
|
||||
/**
|
||||
* You need to set this option if you want to disable use of HTTP Upgrade.
|
||||
* Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used.
|
||||
* You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving.
|
||||
* The upgrade is not disallowed (upgrade is allowed) by default.
|
||||
*/
|
||||
MHD_D_O_DISALLOW_UPGRADE = 322
|
||||
,
|
||||
|
||||
/**
|
||||
* Disable #MHD_action_suspend() functionality.
|
||||
*
|
||||
You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
|
||||
* The suspend is not disallowed (suspend is allowed) by default.
|
||||
*/
|
||||
MHD_D_O_DISALLOW_SUSPEND_RESUME = 323
|
||||
,
|
||||
|
||||
/**
|
||||
* Set a callback to be called for pre-start finalisation.
|
||||
*
|
||||
The specified callback will be called one time, after network initialisation, TLS pre-initialisation, but before the start of the internal threads (if allowed)
|
||||
*/
|
||||
MHD_D_O_DAEMON_READY_CALLBACK = 360
|
||||
,
|
||||
|
||||
/**
|
||||
* Set a function that should be called whenever a connection is started or closed.
|
||||
*/
|
||||
MHD_D_O_NOTIFY_CONNECTION = 361
|
||||
,
|
||||
|
||||
/**
|
||||
* Register a function that should be called whenever a stream is started or closed.
|
||||
* For HTTP/1.1 this callback is called one time for every connection.
|
||||
*/
|
||||
MHD_D_O_NOTIFY_STREAM = 362
|
||||
,
|
||||
|
||||
/**
|
||||
* Set strong random data to be used by MHD.
|
||||
* Currently the data is only needed for Digest Auth module.
|
||||
* The recommended size is between 8 and 32 bytes. Security can be lower for sizes less or equal four.
|
||||
* Sizes larger then 32 (or, probably, larger than 16 - debatable) will not increase the security.
|
||||
*/
|
||||
MHD_D_O_RANDOM_ENTROPY = 400
|
||||
,
|
||||
|
||||
/**
|
||||
* Specify the size of the internal hash map array that tracks generated digest nonces usage.
|
||||
* When the size of the map is too small then need to handle concurrent DAuth requests, a lot of stale nonce results will be produced.
|
||||
* By default the size is 8 bytes (very small).
|
||||
*/
|
||||
MHD_D_O_DAUTH_MAP_SIZE = 401
|
||||
,
|
||||
|
||||
/**
|
||||
* Control the scope of validity of MHD-generated nonces.
|
||||
* This regulates how nonces are generated and how nonces are checked by #MHD_digest_auth_check() and similar functions.
|
||||
* This option allows bitwise OR combination of #MHD_DaemonOptionValueDAuthBindNonce values.
|
||||
* When this option is not used then default value is #MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_NONE.
|
||||
*/
|
||||
MHD_D_O_DAUTH_NONCE_BIND_TYPE = 402
|
||||
,
|
||||
|
||||
/**
|
||||
* Default nonce timeout value (in seconds) used for Digest Auth.
|
||||
* Silently ignored if followed by zero value.
|
||||
* @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
|
||||
*/
|
||||
MHD_D_O_DAUTH_DEF_NONCE_TIMEOUT = 403
|
||||
,
|
||||
|
||||
/**
|
||||
* Default maximum nc (nonce count) value used for Digest Auth.
|
||||
* Silently ignored if followed by zero value.
|
||||
* @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
|
||||
*/
|
||||
MHD_D_O_DAUTH_DEF_MAX_NC = 404
|
||||
,
|
||||
|
||||
/**
|
||||
* The sentinel value.
|
||||
* This value enforces specific underlying integer type for the enum.
|
||||
* Do not use.
|
||||
*/
|
||||
MHD_D_O_SENTINEL = 65535
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_LOG_CALLBACK
|
||||
*/
|
||||
struct MHD_DaemonOptionValueLog
|
||||
{
|
||||
/**
|
||||
* the callback to use for logging,
|
||||
* NULL to disable logging
|
||||
*/
|
||||
MHD_LoggingCallback v_log_cb;
|
||||
|
||||
/**
|
||||
* the closure for the logging callback
|
||||
*/
|
||||
void *v_lob_cb_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_BIND_PORT
|
||||
*/
|
||||
struct MHD_DaemonOptionValueBind
|
||||
{
|
||||
/**
|
||||
* the address family to use,
|
||||
* the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used)
|
||||
*/
|
||||
enum MHD_AddressFamily v_af;
|
||||
|
||||
/**
|
||||
* port to use, 0 to let system assign any free port,
|
||||
* ignored if @a af is #MHD_AF_NONE
|
||||
*/
|
||||
uint_fast16_t v_port;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_BIND_SA
|
||||
*/
|
||||
struct MHD_DaemonOptionValueSA
|
||||
{
|
||||
/**
|
||||
* the size of the socket address pointed by @a sa.
|
||||
*/
|
||||
size_t v_sa_len;
|
||||
|
||||
/**
|
||||
* the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX)
|
||||
*/
|
||||
const struct sockaddr *v_sa;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_TCP_FASTOPEN
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTFO
|
||||
{
|
||||
/**
|
||||
* the type use of of TCP FastOpen
|
||||
*/
|
||||
enum MHD_TCPFastOpenType v_option;
|
||||
|
||||
/**
|
||||
* the length of the queue, zero to use system or MHD default,
|
||||
* silently ignored on platforms without support for custom queue size
|
||||
*/
|
||||
unsigned int v_queue_length;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_TLS_KEY_CERT
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTlsCert
|
||||
{
|
||||
/**
|
||||
* the private key loaded into memory (not a filename)
|
||||
*/
|
||||
const char *v_mem_key;
|
||||
|
||||
/**
|
||||
* the certificate loaded into memory (not a filename)
|
||||
*/
|
||||
const char *v_mem_cert;
|
||||
|
||||
/**
|
||||
* the option passphrase phrase to decrypt the private key,
|
||||
* could be NULL is private does not need a password
|
||||
*/
|
||||
const char *v_mem_pass;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_TLS_PSK_CALLBACK
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTlsPskCB
|
||||
{
|
||||
/**
|
||||
* the function to call to obtain pre-shared key
|
||||
*/
|
||||
MHD_PskServerCredentialsCallback v_psk_cb;
|
||||
|
||||
/**
|
||||
* the closure for @a psk_cb
|
||||
*/
|
||||
void *v_psk_cb_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_ACCEPT_POLICY
|
||||
*/
|
||||
struct MHD_DaemonOptionValueAcceptPol
|
||||
{
|
||||
/**
|
||||
* the accept policy callback
|
||||
*/
|
||||
MHD_AcceptPolicyCallback v_apc;
|
||||
|
||||
/**
|
||||
* the closure for the callback
|
||||
*/
|
||||
void *v_apc_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_PROTOCOL_STRICT_LEVEL
|
||||
*/
|
||||
struct MHD_DaemonOptionValueStrctLvl
|
||||
{
|
||||
/**
|
||||
* the level of strictness
|
||||
*/
|
||||
enum MHD_ProtocolStrictLevel v_sl;
|
||||
|
||||
/**
|
||||
* the way how to use the requested level
|
||||
*/
|
||||
enum MHD_UseStictLevel v_how;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_EARLY_URI_LOGGER
|
||||
*/
|
||||
struct MHD_DaemonOptionValueUriCB
|
||||
{
|
||||
/**
|
||||
* the early URI callback
|
||||
*/
|
||||
MHD_EarlyUriLogCallback v_cb;
|
||||
|
||||
/**
|
||||
* the closure for the callback
|
||||
*/
|
||||
void *v_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_DAEMON_READY_CALLBACK
|
||||
*/
|
||||
struct MHD_DaemonOptionValueReadyCB
|
||||
{
|
||||
/**
|
||||
* the pre-start callback
|
||||
*/
|
||||
MHD_DaemonReadyCallback v_cb;
|
||||
|
||||
/**
|
||||
* the closure for the callback
|
||||
*/
|
||||
void *v_cb_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_NOTIFY_CONNECTION
|
||||
*/
|
||||
struct MHD_DaemonOptionValueNotifConnCB
|
||||
{
|
||||
/**
|
||||
* the callback for notifications
|
||||
*/
|
||||
MHD_NotifyConnectionCallback v_ncc;
|
||||
|
||||
/**
|
||||
* the closure for the callback
|
||||
*/
|
||||
void *v_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_NOTIFY_STREAM
|
||||
*/
|
||||
struct MHD_DaemonOptionValueNotifStreamCB
|
||||
{
|
||||
/**
|
||||
* the callback for notifications
|
||||
*/
|
||||
MHD_NotifyStreamCallback v_nsc;
|
||||
|
||||
/**
|
||||
* the closure for the callback
|
||||
*/
|
||||
void *v_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_D_O_RANDOM_ENTROPY
|
||||
*/
|
||||
struct MHD_DaemonOptionValueRand
|
||||
{
|
||||
/**
|
||||
* the size of the buffer
|
||||
*/
|
||||
size_t v_buf_size;
|
||||
|
||||
/**
|
||||
* the buffer with strong random data, the content will be copied by MHD
|
||||
*/
|
||||
const void *v_buf;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters for MHD daemon options
|
||||
*/
|
||||
union MHD_DaemonOptionValue
|
||||
{
|
||||
/**
|
||||
* Value for #MHD_D_O_WORK_MODE.
|
||||
* the object created by one of the next functions/macros: #MHD_WM_OPTION_EXTERNAL_PERIODIC(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(), #MHD_WM_OPTION_WORKER_THREADS(), #MHD_WM_OPTION_THREAD_PER_CONNECTION()
|
||||
*/
|
||||
struct MHD_WorkModeWithParam work_mode;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_POLL_SYSCALL.
|
||||
* FIXME
|
||||
*/
|
||||
enum MHD_SockPollSyscall poll_syscall;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LOG_CALLBACK.
|
||||
* the callback to use for logging,
|
||||
* NULL to disable logging
|
||||
*/
|
||||
struct MHD_DaemonOptionValueLog log_callback;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_BIND_PORT.
|
||||
* the address family to use,
|
||||
* the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used)
|
||||
*/
|
||||
struct MHD_DaemonOptionValueBind bind_port;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_BIND_SA.
|
||||
* the size of the socket address pointed by @a sa.
|
||||
*/
|
||||
struct MHD_DaemonOptionValueSA bind_sa;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LISTEN_SOCKET.
|
||||
* the listen socket to use, ignored if set to #MHD_INVALID_SOCKET
|
||||
*/
|
||||
MHD_socket listen_socket;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LISTEN_ADDR_REUSE.
|
||||
* FIXME
|
||||
*/
|
||||
enum MHD_DaemonOptionBindType listen_addr_reuse;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TCP_FASTOPEN.
|
||||
* the type use of of TCP FastOpen
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTFO tcp_fastopen;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LISTEN_BACKLOG.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int listen_backlog;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_SIGPIPE_SUPPRESSED.
|
||||
*/
|
||||
enum MHD_Bool sigpipe_suppressed;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS.
|
||||
* the TLS backend to use,
|
||||
* #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections
|
||||
*/
|
||||
enum MHD_TlsBackend tls;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS_KEY_CERT.
|
||||
* the private key loaded into memory (not a filename)
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTlsCert tls_key_cert;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS_CLIENT_CA.
|
||||
* the CA certificate in memory (not a filename)
|
||||
*/
|
||||
const char *tls_client_ca;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS_PSK_CALLBACK.
|
||||
* the function to call to obtain pre-shared key
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTlsPskCB tls_psk_callback;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_NO_ALPN.
|
||||
*/
|
||||
enum MHD_Bool no_alpn;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DEFAULT_TIMEOUT.
|
||||
* the in seconds, zero for no timeout
|
||||
*/
|
||||
unsigned int default_timeout;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_GLOBAL_CONNECTION_LIMIT.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int global_connection_limit;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_PER_IP_LIMIT.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int per_ip_limit;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_ACCEPT_POLICY.
|
||||
* the accept policy callback
|
||||
*/
|
||||
struct MHD_DaemonOptionValueAcceptPol accept_policy;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_PROTOCOL_STRICT_LEVEL.
|
||||
* the level of strictness
|
||||
*/
|
||||
struct MHD_DaemonOptionValueStrctLvl protocol_strict_level;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_EARLY_URI_LOGGER.
|
||||
* the early URI callback
|
||||
*/
|
||||
struct MHD_DaemonOptionValueUriCB early_uri_logger;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE.
|
||||
*/
|
||||
enum MHD_Bool disable_uri_query_plus_as_space;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_SUPPRESS_DATE_HEADER.
|
||||
*/
|
||||
enum MHD_Bool suppress_date_header;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_ENABLE_SHOUTCAST.
|
||||
*/
|
||||
enum MHD_Bool enable_shoutcast;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_CONN_MEMORY_LIMIT.
|
||||
*/
|
||||
size_t conn_memory_limit;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LARGE_POOL_SIZE.
|
||||
*/
|
||||
size_t large_pool_size;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_STACK_SIZE.
|
||||
*/
|
||||
size_t stack_size;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_FD_NUMBER_LIMIT.
|
||||
* FIXME
|
||||
*/
|
||||
MHD_socket fd_number_limit;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TURBO.
|
||||
*/
|
||||
enum MHD_Bool turbo;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISABLE_THREAD_SAFETY.
|
||||
*/
|
||||
enum MHD_Bool disable_thread_safety;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISALLOW_UPGRADE.
|
||||
*/
|
||||
enum MHD_Bool disallow_upgrade;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISALLOW_SUSPEND_RESUME.
|
||||
*/
|
||||
enum MHD_Bool disallow_suspend_resume;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAEMON_READY_CALLBACK.
|
||||
* the pre-start callback
|
||||
*/
|
||||
struct MHD_DaemonOptionValueReadyCB daemon_ready_callback;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_NOTIFY_CONNECTION.
|
||||
* the callback for notifications
|
||||
*/
|
||||
struct MHD_DaemonOptionValueNotifConnCB notify_connection;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_NOTIFY_STREAM.
|
||||
* the callback for notifications
|
||||
*/
|
||||
struct MHD_DaemonOptionValueNotifStreamCB notify_stream;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_RANDOM_ENTROPY.
|
||||
* the size of the buffer
|
||||
*/
|
||||
struct MHD_DaemonOptionValueRand random_entropy;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_MAP_SIZE.
|
||||
* the size of the map array
|
||||
*/
|
||||
size_t dauth_map_size;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_NONCE_BIND_TYPE.
|
||||
* FIXME
|
||||
*/
|
||||
enum MHD_DaemonOptionValueDAuthBindNonce dauth_nonce_bind_type;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_DEF_NONCE_TIMEOUT.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int dauth_def_nonce_timeout;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_DEF_MAX_NC.
|
||||
* FIXME
|
||||
*/
|
||||
uint_fast32_t dauth_def_max_nc;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct MHD_DaemonOptionAndValue
|
||||
{
|
||||
/**
|
||||
* The daemon configuration option
|
||||
*/
|
||||
enum MHD_DaemonOption opt;
|
||||
|
||||
/**
|
||||
* The value for the @a opt option
|
||||
*/
|
||||
union MHD_DaemonOptionValue val;
|
||||
};
|
||||
|
||||
#if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_DESIG_NEST_INIT)
|
||||
/**
|
||||
* Set MHD work (threading and polling) mode.
|
||||
* Consider use of #MHD_D_OPTION_WM_EXTERNAL_PERIODIC(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_D_OPTION_WM_EXTERNAL_SINGLE_FD_WATCH(), #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION() instead of direct use of this parameter.
|
||||
* @param wmp the object created by one of the next functions/macros: #MHD_WM_OPTION_EXTERNAL_PERIODIC(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(), #MHD_WM_OPTION_WORKER_THREADS(), #MHD_WM_OPTION_THREAD_PER_CONNECTION()
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_WORK_MODE(wmp) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_WORK_MODE, \
|
||||
.val.work_mode = (wmp) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Select a sockets watch system call used for internal polling.
|
||||
* @param els FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_POLL_SYSCALL(els) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_POLL_SYSCALL, \
|
||||
.val.poll_syscall = (els) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set a callback to use for logging
|
||||
* @param log_cb the callback to use for logging,
|
||||
* NULL to disable logging
|
||||
* @param lob_cb_cls the closure for the logging callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_LOG_CALLBACK(log_cb,lob_cb_cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_LOG_CALLBACK, \
|
||||
.val.log_callback.v_log_cb = (log_cb), \
|
||||
.val.log_callback.v_lob_cb_cls = (lob_cb_cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Bind to the given TCP port and address family.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_SA() or #MHD_D_OPTION_LISTEN_SOCKET().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
* @param af the address family to use,
|
||||
* the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used)
|
||||
* @param port port to use, 0 to let system assign any free port,
|
||||
* ignored if @a af is #MHD_AF_NONE
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_BIND_PORT(af,port) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_BIND_PORT, \
|
||||
.val.bind_port.v_af = (af), \
|
||||
.val.bind_port.v_port = (port) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Bind to the given socket address.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_LISTEN_SOCKET().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
* @param sa_len the size of the socket address pointed by @a sa.
|
||||
* @param sa the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX)
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_BIND_SA(sa_len,sa) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_BIND_SA, \
|
||||
.val.bind_sa.v_sa_len = (sa_len), \
|
||||
.val.bind_sa.v_sa = (sa) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Accept connections from the given socket. Socket
|
||||
* must be a TCP or UNIX domain (SOCK_STREAM) socket.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
* @param listen_fd the listen socket to use, ignored if set to #MHD_INVALID_SOCKET
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_LISTEN_SOCKET(listen_fd) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_LISTEN_SOCKET, \
|
||||
.val.listen_socket = (listen_fd) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Select mode of reusing address:port listen address.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* @param reuse_type FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_LISTEN_ADDR_REUSE(reuse_type) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_LISTEN_ADDR_REUSE, \
|
||||
.val.listen_addr_reuse = (reuse_type) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Configure TCP_FASTOPEN option, including setting a
|
||||
* custom @a queue_length.
|
||||
*
|
||||
Note that having a larger queue size can cause resource exhaustion
|
||||
* attack as the TCP stack has to now allocate resources for the SYN
|
||||
* packet along with its DATA.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* @param option the type use of of TCP FastOpen
|
||||
* @param queue_length the length of the queue, zero to use system or MHD default,
|
||||
* silently ignored on platforms without support for custom queue size
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_TCP_FASTOPEN(option,queue_length) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_TCP_FASTOPEN, \
|
||||
.val.tcp_fastopen.v_option = (option), \
|
||||
.val.tcp_fastopen.v_queue_length = (queue_length) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Use the given backlog for the listen() call.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* @param backlog_size FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_LISTEN_BACKLOG(backlog_size) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_LISTEN_BACKLOG, \
|
||||
.val.listen_backlog = (backlog_size) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Inform that SIGPIPE is suppressed or handled by application.
|
||||
* If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`.
|
||||
* Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_SIGPIPE_SUPPRESSED(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_SIGPIPE_SUPPRESSED, \
|
||||
.val.sigpipe_suppressed = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Enable TLS (HTTPS) and select TLS backend
|
||||
* @param backend the TLS backend to use,
|
||||
* #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_TLS(backend) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_TLS, \
|
||||
.val.tls = (backend) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Provide TLS key and certificate data in-memory.
|
||||
* Works only if TLS mode is enabled.
|
||||
* @param mem_key the private key loaded into memory (not a filename)
|
||||
* @param mem_cert the certificate loaded into memory (not a filename)
|
||||
* @param mem_pass the option passphrase phrase to decrypt the private key,
|
||||
* could be NULL is private does not need a password
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_TLS_KEY_CERT(mem_key,mem_cert,mem_pass) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_TLS_KEY_CERT, \
|
||||
.val.tls_key_cert.v_mem_key = (mem_key), \
|
||||
.val.tls_key_cert.v_mem_cert = (mem_cert), \
|
||||
.val.tls_key_cert.v_mem_pass = (mem_pass) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Provide the certificate of the certificate authority (CA) to be used by the MHD daemon for client authentication.
|
||||
* Works only if TLS mode is enabled.
|
||||
* @param mem_client_ca the CA certificate in memory (not a filename)
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_TLS_CLIENT_CA(mem_client_ca) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_TLS_CLIENT_CA, \
|
||||
.val.tls_client_ca = (mem_client_ca) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Configure PSK to use for the TLS key exchange.
|
||||
* @param psk_cb the function to call to obtain pre-shared key
|
||||
* @param psk_cb_cls the closure for @a psk_cb
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_TLS_PSK_CALLBACK(psk_cb,psk_cb_cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_TLS_PSK_CALLBACK, \
|
||||
.val.tls_psk_callback.v_psk_cb = (psk_cb), \
|
||||
.val.tls_psk_callback.v_psk_cb_cls = (psk_cb_cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Control ALPN for TLS connection.
|
||||
* Silently ignored for non-TLS.
|
||||
* By default ALPN is automatically used for TLS connections.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_NO_ALPN(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_NO_ALPN, \
|
||||
.val.no_alpn = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Specify inactivity timeout for connection.
|
||||
* When no activity for specified time on connection, it is closed automatically.
|
||||
* Use zero for no timeout, which is also the (unsafe!) default.
|
||||
* @param timeout the in seconds, zero for no timeout
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DEFAULT_TIMEOUT(timeout) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DEFAULT_TIMEOUT, \
|
||||
.val.default_timeout = (timeout) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Maximum number of (concurrent) network connections served by daemon
|
||||
* @param glob_limit FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_GLOBAL_CONNECTION_LIMIT(glob_limit) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_GLOBAL_CONNECTION_LIMIT, \
|
||||
.val.global_connection_limit = (glob_limit) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Limit on the number of (concurrent) network connections made to the server from the same IP address.
|
||||
* Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected.
|
||||
* @param per_ip_limit FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_PER_IP_LIMIT(per_ip_limit) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_PER_IP_LIMIT, \
|
||||
.val.per_ip_limit = (per_ip_limit) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set a policy callback that accepts/rejects connections based on the client's IP address. The callbeck function will be called before servicing any new incoming connection.
|
||||
* @param apc the accept policy callback
|
||||
* @param apc_cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_ACCEPT_POLICY(apc,apc_cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_ACCEPT_POLICY, \
|
||||
.val.accept_policy.v_apc = (apc), \
|
||||
.val.accept_policy.v_apc_cls = (apc_cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set how strictly MHD will enforce the HTTP protocol.
|
||||
* @param sl the level of strictness
|
||||
* @param how the way how to use the requested level
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_PROTOCOL_STRICT_LEVEL(sl,how) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_PROTOCOL_STRICT_LEVEL, \
|
||||
.val.protocol_strict_level.v_sl = (sl), \
|
||||
.val.protocol_strict_level.v_how = (how) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set a callback to be called first for every request when the request line is received (before any parsing of the header).
|
||||
* This callback is the only way to get raw (unmodified) request URI as URI is parsed and modified by MHD in-place.
|
||||
* Mandatory URI modification may apply before this call, like binary zero replacement, as required by RFCs.
|
||||
* @param cb the early URI callback
|
||||
* @param cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_EARLY_URI_LOGGER(cb,cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_EARLY_URI_LOGGER, \
|
||||
.val.early_uri_logger.v_cb = (cb), \
|
||||
.val.early_uri_logger.v_cls = (cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Disable converting plus ('+') character to space in GET parameters (URI part after '?').
|
||||
* Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details.
|
||||
* By default plus is converted to space in the query part of URI.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE, \
|
||||
.val.disable_uri_query_plus_as_space = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Suppresse use of 'Date:' header.
|
||||
* According to RFC should be suppressed only if the system has no RTC.
|
||||
* The 'Date:' is not suppressed (the header is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_SUPPRESS_DATE_HEADER(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_SUPPRESS_DATE_HEADER, \
|
||||
.val.suppress_date_header = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Use SHOUTcast for responses.
|
||||
* This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_ENABLE_SHOUTCAST(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_ENABLE_SHOUTCAST, \
|
||||
.val.enable_shoutcast = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Maximum memory size per connection.
|
||||
* Default is 32kb.
|
||||
* Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.
|
||||
* The size should be large enough to fit all request headers (together with internal parsing information).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_CONN_MEMORY_LIMIT(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_CONN_MEMORY_LIMIT, \
|
||||
.val.conn_memory_limit = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* The size of the shared memory pool for accamulated upload processing.
|
||||
* The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application.
|
||||
* Default is 8Mb.
|
||||
* Can be set to zero to disable share pool.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_LARGE_POOL_SIZE(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_LARGE_POOL_SIZE, \
|
||||
.val.large_pool_size = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Desired size of the stack for the threads started by MHD.
|
||||
* Use 0 for system default, which is also MHD default.
|
||||
* Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_STACK_SIZE(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_STACK_SIZE, \
|
||||
.val.stack_size = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* The the maximum FD value.
|
||||
* The limit is applied to all sockets used by MHD.
|
||||
* If listen socket FD is equal or higher that specified value, the daemon fail to start.
|
||||
* If new connection FD is equal or higher that specified value, the connection is rejected.
|
||||
* Useful if application uses select() for polling the sockets, system FD_SETSIZE is good value for this option in such case.
|
||||
* Does not work with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* Does not work on W32 (WinSock sockets).
|
||||
* @param max_fd FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_FD_NUMBER_LIMIT(max_fd) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_FD_NUMBER_LIMIT, \
|
||||
.val.fd_number_limit = (max_fd) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Enable `turbo`.
|
||||
* Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
|
||||
* Most effects only happen with internal threads with epoll.
|
||||
* The 'turbo' mode is not enabled (mode is disabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_TURBO(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_TURBO, \
|
||||
.val.turbo = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Disable some internal thread safety.
|
||||
* Indicates that MHD daemon will be used by application in single-threaded mode only. When this flag is set then application must call any MHD function only within a single thread.
|
||||
* This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment.
|
||||
* Not compatible with any internal threads modes.
|
||||
* If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory.
|
||||
* Thread safety is not disabled (safety is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISABLE_THREAD_SAFETY(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISABLE_THREAD_SAFETY, \
|
||||
.val.disable_thread_safety = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* You need to set this option if you want to disable use of HTTP Upgrade.
|
||||
* Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used.
|
||||
* You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving.
|
||||
* The upgrade is not disallowed (upgrade is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISALLOW_UPGRADE(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISALLOW_UPGRADE, \
|
||||
.val.disallow_upgrade = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Disable #MHD_action_suspend() functionality.
|
||||
*
|
||||
You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
|
||||
* The suspend is not disallowed (suspend is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISALLOW_SUSPEND_RESUME(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISALLOW_SUSPEND_RESUME, \
|
||||
.val.disallow_suspend_resume = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set a callback to be called for pre-start finalisation.
|
||||
*
|
||||
The specified callback will be called one time, after network initialisation, TLS pre-initialisation, but before the start of the internal threads (if allowed)
|
||||
* @param cb the pre-start callback
|
||||
* @param cb_cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DAEMON_READY_CALLBACK(cb,cb_cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DAEMON_READY_CALLBACK, \
|
||||
.val.daemon_ready_callback.v_cb = (cb), \
|
||||
.val.daemon_ready_callback.v_cb_cls = (cb_cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set a function that should be called whenever a connection is started or closed.
|
||||
* @param ncc the callback for notifications
|
||||
* @param cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_NOTIFY_CONNECTION(ncc,cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_NOTIFY_CONNECTION, \
|
||||
.val.notify_connection.v_ncc = (ncc), \
|
||||
.val.notify_connection.v_cls = (cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Register a function that should be called whenever a stream is started or closed.
|
||||
* For HTTP/1.1 this callback is called one time for every connection.
|
||||
* @param nsc the callback for notifications
|
||||
* @param cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_NOTIFY_STREAM(nsc,cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_NOTIFY_STREAM, \
|
||||
.val.notify_stream.v_nsc = (nsc), \
|
||||
.val.notify_stream.v_cls = (cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set strong random data to be used by MHD.
|
||||
* Currently the data is only needed for Digest Auth module.
|
||||
* The recommended size is between 8 and 32 bytes. Security can be lower for sizes less or equal four.
|
||||
* Sizes larger then 32 (or, probably, larger than 16 - debatable) will not increase the security.
|
||||
* @param buf_size the size of the buffer
|
||||
* @param buf the buffer with strong random data, the content will be copied by MHD
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_RANDOM_ENTROPY(buf_size,buf) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_RANDOM_ENTROPY, \
|
||||
.val.random_entropy.v_buf_size = (buf_size), \
|
||||
.val.random_entropy.v_buf = (buf) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Specify the size of the internal hash map array that tracks generated digest nonces usage.
|
||||
* When the size of the map is too small then need to handle concurrent DAuth requests, a lot of stale nonce results will be produced.
|
||||
* By default the size is 8 bytes (very small).
|
||||
* @param size the size of the map array
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DAUTH_MAP_SIZE(size) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DAUTH_MAP_SIZE, \
|
||||
.val.dauth_map_size = (size) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Control the scope of validity of MHD-generated nonces.
|
||||
* This regulates how nonces are generated and how nonces are checked by #MHD_digest_auth_check() and similar functions.
|
||||
* This option allows bitwise OR combination of #MHD_DaemonOptionValueDAuthBindNonce values.
|
||||
* When this option is not used then default value is #MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_NONE.
|
||||
* @param bind_type FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DAUTH_NONCE_BIND_TYPE(bind_type) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DAUTH_NONCE_BIND_TYPE, \
|
||||
.val.dauth_nonce_bind_type = (bind_type) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Default nonce timeout value (in seconds) used for Digest Auth.
|
||||
* Silently ignored if followed by zero value.
|
||||
* @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
|
||||
* @param timeout FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DAUTH_DEF_NONCE_TIMEOUT(timeout) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DAUTH_DEF_NONCE_TIMEOUT, \
|
||||
.val.dauth_def_nonce_timeout = (timeout) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Default maximum nc (nonce count) value used for Digest Auth.
|
||||
* Silently ignored if followed by zero value.
|
||||
* @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
|
||||
* @param max_nc FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DAUTH_DEF_MAX_NC(max_nc) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DAUTH_DEF_MAX_NC, \
|
||||
.val.dauth_def_max_nc = (max_nc) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Terminate the list of the options
|
||||
* @return the terminating object of struct MHD_DaemonOptionAndValue
|
||||
*/
|
||||
# define MHD_D_OPTION_TERMINATE() \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_D_O_END) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
#else /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
||||
MHD_NOWARN_UNUSED_FUNC_
|
||||
/**
|
||||
* Set MHD work (threading and polling) mode.
|
||||
* Consider use of #MHD_D_OPTION_WM_EXTERNAL_PERIODIC(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_D_OPTION_WM_EXTERNAL_SINGLE_FD_WATCH(), #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION() instead of direct use of this parameter.
|
||||
* @param wmp the object created by one of the next functions/macros: #MHD_WM_OPTION_EXTERNAL_PERIODIC(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(), #MHD_WM_OPTION_WORKER_THREADS(), #MHD_WM_OPTION_THREAD_PER_CONNECTION()
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_WORK_MODE (
|
||||
struct MHD_WorkModeWithParam wmp
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_WORK_MODE;
|
||||
opt_val.val.work_mode = wmp;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select a sockets watch system call used for internal polling.
|
||||
* @param els FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_POLL_SYSCALL (
|
||||
enum MHD_SockPollSyscall els
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_POLL_SYSCALL;
|
||||
opt_val.val.poll_syscall = els;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a callback to use for logging
|
||||
* @param log_cb the callback to use for logging,
|
||||
* NULL to disable logging
|
||||
* @param lob_cb_cls the closure for the logging callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_LOG_CALLBACK (
|
||||
MHD_LoggingCallback log_cb,
|
||||
void *lob_cb_cls
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_LOG_CALLBACK;
|
||||
opt_val.val.log_callback.v_log_cb = log_cb;
|
||||
opt_val.val.log_callback.v_lob_cb_cls = lob_cb_cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind to the given TCP port and address family.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_SA() or #MHD_D_OPTION_LISTEN_SOCKET().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
* @param af the address family to use,
|
||||
* the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used)
|
||||
* @param port port to use, 0 to let system assign any free port,
|
||||
* ignored if @a af is #MHD_AF_NONE
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_BIND_PORT (
|
||||
enum MHD_AddressFamily af,
|
||||
uint_fast16_t port
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_BIND_PORT;
|
||||
opt_val.val.bind_port.v_af = af;
|
||||
opt_val.val.bind_port.v_port = port;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind to the given socket address.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_LISTEN_SOCKET().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
* @param sa_len the size of the socket address pointed by @a sa.
|
||||
* @param sa the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX)
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_BIND_SA (
|
||||
size_t sa_len,
|
||||
const struct sockaddr *sa
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_BIND_SA;
|
||||
opt_val.val.bind_sa.v_sa_len = sa_len;
|
||||
opt_val.val.bind_sa.v_sa = sa;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Accept connections from the given socket. Socket
|
||||
* must be a TCP or UNIX domain (SOCK_STREAM) socket.
|
||||
*
|
||||
Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA().
|
||||
*
|
||||
If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection.
|
||||
* @param listen_fd the listen socket to use, ignored if set to #MHD_INVALID_SOCKET
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_LISTEN_SOCKET (
|
||||
MHD_socket listen_fd
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_LISTEN_SOCKET;
|
||||
opt_val.val.listen_socket = listen_fd;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select mode of reusing address:port listen address.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* @param reuse_type FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_LISTEN_ADDR_REUSE (
|
||||
enum MHD_DaemonOptionBindType reuse_type
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_LISTEN_ADDR_REUSE;
|
||||
opt_val.val.listen_addr_reuse = reuse_type;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure TCP_FASTOPEN option, including setting a
|
||||
* custom @a queue_length.
|
||||
*
|
||||
Note that having a larger queue size can cause resource exhaustion
|
||||
* attack as the TCP stack has to now allocate resources for the SYN
|
||||
* packet along with its DATA.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* @param option the type use of of TCP FastOpen
|
||||
* @param queue_length the length of the queue, zero to use system or MHD default,
|
||||
* silently ignored on platforms without support for custom queue size
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_TCP_FASTOPEN (
|
||||
enum MHD_TCPFastOpenType option,
|
||||
unsigned int queue_length
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_TCP_FASTOPEN;
|
||||
opt_val.val.tcp_fastopen.v_option = option;
|
||||
opt_val.val.tcp_fastopen.v_queue_length = queue_length;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use the given backlog for the listen() call.
|
||||
*
|
||||
Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* @param backlog_size FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_LISTEN_BACKLOG (
|
||||
unsigned int backlog_size
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_LISTEN_BACKLOG;
|
||||
opt_val.val.listen_backlog = backlog_size;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inform that SIGPIPE is suppressed or handled by application.
|
||||
* If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`.
|
||||
* Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_SIGPIPE_SUPPRESSED (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_SIGPIPE_SUPPRESSED;
|
||||
opt_val.val.sigpipe_suppressed = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable TLS (HTTPS) and select TLS backend
|
||||
* @param backend the TLS backend to use,
|
||||
* #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_TLS (
|
||||
enum MHD_TlsBackend backend
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_TLS;
|
||||
opt_val.val.tls = backend;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provide TLS key and certificate data in-memory.
|
||||
* Works only if TLS mode is enabled.
|
||||
* @param mem_key the private key loaded into memory (not a filename)
|
||||
* @param mem_cert the certificate loaded into memory (not a filename)
|
||||
* @param mem_pass the option passphrase phrase to decrypt the private key,
|
||||
* could be NULL is private does not need a password
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_TLS_KEY_CERT (
|
||||
const char *mem_key,
|
||||
const char *mem_cert,
|
||||
const char *mem_pass
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_TLS_KEY_CERT;
|
||||
opt_val.val.tls_key_cert.v_mem_key = mem_key;
|
||||
opt_val.val.tls_key_cert.v_mem_cert = mem_cert;
|
||||
opt_val.val.tls_key_cert.v_mem_pass = mem_pass;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provide the certificate of the certificate authority (CA) to be used by the MHD daemon for client authentication.
|
||||
* Works only if TLS mode is enabled.
|
||||
* @param mem_client_ca the CA certificate in memory (not a filename)
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_TLS_CLIENT_CA (
|
||||
const char *mem_client_ca
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_TLS_CLIENT_CA;
|
||||
opt_val.val.tls_client_ca = mem_client_ca;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure PSK to use for the TLS key exchange.
|
||||
* @param psk_cb the function to call to obtain pre-shared key
|
||||
* @param psk_cb_cls the closure for @a psk_cb
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_TLS_PSK_CALLBACK (
|
||||
MHD_PskServerCredentialsCallback psk_cb,
|
||||
void *psk_cb_cls
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_TLS_PSK_CALLBACK;
|
||||
opt_val.val.tls_psk_callback.v_psk_cb = psk_cb;
|
||||
opt_val.val.tls_psk_callback.v_psk_cb_cls = psk_cb_cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Control ALPN for TLS connection.
|
||||
* Silently ignored for non-TLS.
|
||||
* By default ALPN is automatically used for TLS connections.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_NO_ALPN (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_NO_ALPN;
|
||||
opt_val.val.no_alpn = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify inactivity timeout for connection.
|
||||
* When no activity for specified time on connection, it is closed automatically.
|
||||
* Use zero for no timeout, which is also the (unsafe!) default.
|
||||
* @param timeout the in seconds, zero for no timeout
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DEFAULT_TIMEOUT (
|
||||
unsigned int timeout
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DEFAULT_TIMEOUT;
|
||||
opt_val.val.default_timeout = timeout;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Maximum number of (concurrent) network connections served by daemon
|
||||
* @param glob_limit FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_GLOBAL_CONNECTION_LIMIT (
|
||||
unsigned int glob_limit
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_GLOBAL_CONNECTION_LIMIT;
|
||||
opt_val.val.global_connection_limit = glob_limit;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Limit on the number of (concurrent) network connections made to the server from the same IP address.
|
||||
* Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected.
|
||||
* @param per_ip_limit FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_PER_IP_LIMIT (
|
||||
unsigned int per_ip_limit
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_PER_IP_LIMIT;
|
||||
opt_val.val.per_ip_limit = per_ip_limit;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a policy callback that accepts/rejects connections based on the client's IP address. The callbeck function will be called before servicing any new incoming connection.
|
||||
* @param apc the accept policy callback
|
||||
* @param apc_cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_ACCEPT_POLICY (
|
||||
MHD_AcceptPolicyCallback apc,
|
||||
void *apc_cls
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_ACCEPT_POLICY;
|
||||
opt_val.val.accept_policy.v_apc = apc;
|
||||
opt_val.val.accept_policy.v_apc_cls = apc_cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set how strictly MHD will enforce the HTTP protocol.
|
||||
* @param sl the level of strictness
|
||||
* @param how the way how to use the requested level
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_PROTOCOL_STRICT_LEVEL (
|
||||
enum MHD_ProtocolStrictLevel sl,
|
||||
enum MHD_UseStictLevel how
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_PROTOCOL_STRICT_LEVEL;
|
||||
opt_val.val.protocol_strict_level.v_sl = sl;
|
||||
opt_val.val.protocol_strict_level.v_how = how;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a callback to be called first for every request when the request line is received (before any parsing of the header).
|
||||
* This callback is the only way to get raw (unmodified) request URI as URI is parsed and modified by MHD in-place.
|
||||
* Mandatory URI modification may apply before this call, like binary zero replacement, as required by RFCs.
|
||||
* @param cb the early URI callback
|
||||
* @param cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_EARLY_URI_LOGGER (
|
||||
MHD_EarlyUriLogCallback cb,
|
||||
void *cls
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_EARLY_URI_LOGGER;
|
||||
opt_val.val.early_uri_logger.v_cb = cb;
|
||||
opt_val.val.early_uri_logger.v_cls = cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable converting plus ('+') character to space in GET parameters (URI part after '?').
|
||||
* Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details.
|
||||
* By default plus is converted to space in the query part of URI.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE;
|
||||
opt_val.val.disable_uri_query_plus_as_space = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Suppresse use of 'Date:' header.
|
||||
* According to RFC should be suppressed only if the system has no RTC.
|
||||
* The 'Date:' is not suppressed (the header is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_SUPPRESS_DATE_HEADER (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_SUPPRESS_DATE_HEADER;
|
||||
opt_val.val.suppress_date_header = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use SHOUTcast for responses.
|
||||
* This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_ENABLE_SHOUTCAST (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_ENABLE_SHOUTCAST;
|
||||
opt_val.val.enable_shoutcast = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Maximum memory size per connection.
|
||||
* Default is 32kb.
|
||||
* Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.
|
||||
* The size should be large enough to fit all request headers (together with internal parsing information).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_CONN_MEMORY_LIMIT (
|
||||
size_t val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_CONN_MEMORY_LIMIT;
|
||||
opt_val.val.conn_memory_limit = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The size of the shared memory pool for accamulated upload processing.
|
||||
* The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application.
|
||||
* Default is 8Mb.
|
||||
* Can be set to zero to disable share pool.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_LARGE_POOL_SIZE (
|
||||
size_t val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_LARGE_POOL_SIZE;
|
||||
opt_val.val.large_pool_size = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Desired size of the stack for the threads started by MHD.
|
||||
* Use 0 for system default, which is also MHD default.
|
||||
* Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_STACK_SIZE (
|
||||
size_t val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_STACK_SIZE;
|
||||
opt_val.val.stack_size = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The the maximum FD value.
|
||||
* The limit is applied to all sockets used by MHD.
|
||||
* If listen socket FD is equal or higher that specified value, the daemon fail to start.
|
||||
* If new connection FD is equal or higher that specified value, the connection is rejected.
|
||||
* Useful if application uses select() for polling the sockets, system FD_SETSIZE is good value for this option in such case.
|
||||
* Does not work with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* Does not work on W32 (WinSock sockets).
|
||||
* @param max_fd FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_FD_NUMBER_LIMIT (
|
||||
MHD_socket max_fd
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_FD_NUMBER_LIMIT;
|
||||
opt_val.val.fd_number_limit = max_fd;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable `turbo`.
|
||||
* Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
|
||||
* Most effects only happen with internal threads with epoll.
|
||||
* The 'turbo' mode is not enabled (mode is disabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_TURBO (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_TURBO;
|
||||
opt_val.val.turbo = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable some internal thread safety.
|
||||
* Indicates that MHD daemon will be used by application in single-threaded mode only. When this flag is set then application must call any MHD function only within a single thread.
|
||||
* This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment.
|
||||
* Not compatible with any internal threads modes.
|
||||
* If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory.
|
||||
* Thread safety is not disabled (safety is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_THREAD_SAFETY (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISABLE_THREAD_SAFETY;
|
||||
opt_val.val.disable_thread_safety = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* You need to set this option if you want to disable use of HTTP Upgrade.
|
||||
* Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used.
|
||||
* You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving.
|
||||
* The upgrade is not disallowed (upgrade is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DISALLOW_UPGRADE (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISALLOW_UPGRADE;
|
||||
opt_val.val.disallow_upgrade = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable #MHD_action_suspend() functionality.
|
||||
*
|
||||
You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
|
||||
* The suspend is not disallowed (suspend is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DISALLOW_SUSPEND_RESUME (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISALLOW_SUSPEND_RESUME;
|
||||
opt_val.val.disallow_suspend_resume = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a callback to be called for pre-start finalisation.
|
||||
*
|
||||
The specified callback will be called one time, after network initialisation, TLS pre-initialisation, but before the start of the internal threads (if allowed)
|
||||
* @param cb the pre-start callback
|
||||
* @param cb_cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DAEMON_READY_CALLBACK (
|
||||
MHD_DaemonReadyCallback cb,
|
||||
void *cb_cls
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DAEMON_READY_CALLBACK;
|
||||
opt_val.val.daemon_ready_callback.v_cb = cb;
|
||||
opt_val.val.daemon_ready_callback.v_cb_cls = cb_cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a function that should be called whenever a connection is started or closed.
|
||||
* @param ncc the callback for notifications
|
||||
* @param cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_NOTIFY_CONNECTION (
|
||||
MHD_NotifyConnectionCallback ncc,
|
||||
void *cls
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_NOTIFY_CONNECTION;
|
||||
opt_val.val.notify_connection.v_ncc = ncc;
|
||||
opt_val.val.notify_connection.v_cls = cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a function that should be called whenever a stream is started or closed.
|
||||
* For HTTP/1.1 this callback is called one time for every connection.
|
||||
* @param nsc the callback for notifications
|
||||
* @param cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_NOTIFY_STREAM (
|
||||
MHD_NotifyStreamCallback nsc,
|
||||
void *cls
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_NOTIFY_STREAM;
|
||||
opt_val.val.notify_stream.v_nsc = nsc;
|
||||
opt_val.val.notify_stream.v_cls = cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set strong random data to be used by MHD.
|
||||
* Currently the data is only needed for Digest Auth module.
|
||||
* The recommended size is between 8 and 32 bytes. Security can be lower for sizes less or equal four.
|
||||
* Sizes larger then 32 (or, probably, larger than 16 - debatable) will not increase the security.
|
||||
* @param buf_size the size of the buffer
|
||||
* @param buf the buffer with strong random data, the content will be copied by MHD
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_RANDOM_ENTROPY (
|
||||
size_t buf_size,
|
||||
const void *buf
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_RANDOM_ENTROPY;
|
||||
opt_val.val.random_entropy.v_buf_size = buf_size;
|
||||
opt_val.val.random_entropy.v_buf = buf;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the size of the internal hash map array that tracks generated digest nonces usage.
|
||||
* When the size of the map is too small then need to handle concurrent DAuth requests, a lot of stale nonce results will be produced.
|
||||
* By default the size is 8 bytes (very small).
|
||||
* @param size the size of the map array
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DAUTH_MAP_SIZE (
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DAUTH_MAP_SIZE;
|
||||
opt_val.val.dauth_map_size = size;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Control the scope of validity of MHD-generated nonces.
|
||||
* This regulates how nonces are generated and how nonces are checked by #MHD_digest_auth_check() and similar functions.
|
||||
* This option allows bitwise OR combination of #MHD_DaemonOptionValueDAuthBindNonce values.
|
||||
* When this option is not used then default value is #MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_NONE.
|
||||
* @param bind_type FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DAUTH_NONCE_BIND_TYPE (
|
||||
enum MHD_DaemonOptionValueDAuthBindNonce bind_type
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DAUTH_NONCE_BIND_TYPE;
|
||||
opt_val.val.dauth_nonce_bind_type = bind_type;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default nonce timeout value (in seconds) used for Digest Auth.
|
||||
* Silently ignored if followed by zero value.
|
||||
* @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
|
||||
* @param timeout FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DAUTH_DEF_NONCE_TIMEOUT (
|
||||
unsigned int timeout
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DAUTH_DEF_NONCE_TIMEOUT;
|
||||
opt_val.val.dauth_def_nonce_timeout = timeout;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default maximum nc (nonce count) value used for Digest Auth.
|
||||
* Silently ignored if followed by zero value.
|
||||
* @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
|
||||
* @param max_nc FIXME
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_daemonOptionAndValue
|
||||
MHD_D_OPTION_DAUTH_DEF_MAX_NC (
|
||||
uint_fast32_t max_nc
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DAUTH_DEF_MAX_NC;
|
||||
opt_val.val.dauth_def_max_nc = max_nc;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Terminate the list of the options
|
||||
* @return the terminating object of struct MHD_DaemonOptionAndValue
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_TERMINATE (void)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_END;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
MHD_RESTORE_WARN_UNUSED_FUNC_
|
||||
#endif /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
||||
@@ -0,0 +1,486 @@
|
||||
/**
|
||||
* The options (parameters) for MHD response
|
||||
*/
|
||||
enum MHD_FIXED_ENUM_APP_SET_ MHD_ResponseOption
|
||||
{ /**
|
||||
* Not a real option.
|
||||
* Should not be used directly.
|
||||
* This value indicates the end of the list of the options.
|
||||
*/
|
||||
MHD_R_O_END = 0
|
||||
,
|
||||
|
||||
/**
|
||||
* Make the response object re-usable.
|
||||
* The response will not be consumed by MHD_action_from_response() and must be destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
*/
|
||||
MHD_R_O_REUSABLE = 20
|
||||
,
|
||||
|
||||
/**
|
||||
* Enable special processing of the response as body-less (with undefined body size). No automatic 'Content-Length' or 'Transfer-Encoding: chunked' headers are added when the response is used with #MHD_HTTP_STATUS_NOT_MODIFIED code or to respond to HEAD request.
|
||||
* The flag also allow to set arbitrary 'Content-Length' by #MHD_response_add_header() function.
|
||||
* This flag value can be used only with responses created without body (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic 'Content-Length' header is undesirable in response to HEAD requests.
|
||||
*/
|
||||
MHD_R_O_HEAD_ONLY_RESPONSE = 40
|
||||
,
|
||||
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
*/
|
||||
MHD_R_O_CHUNKED_ENC = 41
|
||||
,
|
||||
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive connections and adds 'Connection: close' header.
|
||||
*/
|
||||
MHD_R_O_CONN_CLOSE = 60
|
||||
,
|
||||
|
||||
/**
|
||||
* Only respond in conservative (dumb) HTTP/1.0-compatible mode.
|
||||
* Response still use HTTP/1.1 version in header, but always close the connection after sending the response and do not use chunked encoding for the response.
|
||||
* You can also set the #MHD_R_O_HTTP_1_0_SERVER flag to force HTTP/1.0 version in the response.
|
||||
* Responses are still compatible with HTTP/1.1.
|
||||
* This option can be used to communicate with some broken client, which does not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
*/
|
||||
MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT = 80
|
||||
,
|
||||
|
||||
/**
|
||||
* Only respond in HTTP/1.0-mode.
|
||||
* Contrary to the #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT flag, the response's HTTP version will always be set to 1.0 and keep-alive connections will be used if explicitly requested by the client.
|
||||
* The 'Connection:' header will be added for both 'close' and 'keep-alive' connections.
|
||||
* Chunked encoding will not be used for the response.
|
||||
* Due to backward compatibility, responses still can be used with HTTP/1.1 clients.
|
||||
* This option can be used to emulate HTTP/1.0 server (for response part only as chunked encoding in requests (if any) is processed by MHD).
|
||||
* With this option HTTP/1.0 server is emulated (with support for 'keep-alive' connections).
|
||||
*/
|
||||
MHD_R_O_HTTP_1_0_SERVER = 81
|
||||
,
|
||||
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP content length option.
|
||||
* Allow to set several 'Content-Length' headers. These headers will be used even with replies without body.
|
||||
*/
|
||||
MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH = 100
|
||||
,
|
||||
|
||||
/**
|
||||
* Set a function to be called once MHD is finished with the request.
|
||||
*/
|
||||
MHD_R_O_TERMINATION_CALLBACK = 121
|
||||
,
|
||||
|
||||
/**
|
||||
* The sentinel value.
|
||||
* This value enforces specific underlying integer type for the enum.
|
||||
* Do not use.
|
||||
*/
|
||||
MHD_R_O_SENTINEL = 65535
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data for #MHD_R_O_TERMINATION_CALLBACK
|
||||
*/
|
||||
struct MHD_ResponeOptionValueTermCB
|
||||
{
|
||||
/**
|
||||
* the function to call,
|
||||
* NULL to not use the callback
|
||||
*/
|
||||
MHD_RequestTerminationCallback v_term_cb;
|
||||
|
||||
/**
|
||||
* the closure for the callback
|
||||
*/
|
||||
void *v_term_cb_cls;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters for MHD response options
|
||||
*/
|
||||
union MHD_ResponseOptionValue
|
||||
{
|
||||
/**
|
||||
* Value for #MHD_R_O_REUSABLE.
|
||||
*/
|
||||
enum MHD_Bool reusable;
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_HEAD_ONLY_RESPONSE.
|
||||
*/
|
||||
enum MHD_Bool head_only_response;
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_CHUNKED_ENC.
|
||||
*/
|
||||
enum MHD_Bool chunked_enc;
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_CONN_CLOSE.
|
||||
*/
|
||||
enum MHD_Bool conn_close;
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT.
|
||||
*/
|
||||
enum MHD_Bool http_1_0_compatible_strict;
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_HTTP_1_0_SERVER.
|
||||
*/
|
||||
enum MHD_Bool http_1_0_server;
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH.
|
||||
*/
|
||||
enum MHD_Bool insanity_header_content_length;
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_TERMINATION_CALLBACK.
|
||||
* the function to call,
|
||||
* NULL to not use the callback
|
||||
*/
|
||||
struct MHD_ResponeOptionValueTermCB termination_callback;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct MHD_ResponseOptionAndValue
|
||||
{
|
||||
/**
|
||||
* The response configuration option
|
||||
*/
|
||||
enum MHD_ResponseOption opt;
|
||||
|
||||
/**
|
||||
* The value for the @a opt option
|
||||
*/
|
||||
union MHD_ResponseOptionValue val;
|
||||
};
|
||||
|
||||
#if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_DESIG_NEST_INIT)
|
||||
/**
|
||||
* Make the response object re-usable.
|
||||
* The response will not be consumed by MHD_action_from_response() and must be destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_REUSABLE(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_REUSABLE, \
|
||||
.val.reusable = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Enable special processing of the response as body-less (with undefined body size). No automatic 'Content-Length' or 'Transfer-Encoding: chunked' headers are added when the response is used with #MHD_HTTP_STATUS_NOT_MODIFIED code or to respond to HEAD request.
|
||||
* The flag also allow to set arbitrary 'Content-Length' by #MHD_response_add_header() function.
|
||||
* This flag value can be used only with responses created without body (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic 'Content-Length' header is undesirable in response to HEAD requests.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_HEAD_ONLY_RESPONSE(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_HEAD_ONLY_RESPONSE, \
|
||||
.val.head_only_response = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_CHUNKED_ENC(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_CHUNKED_ENC, \
|
||||
.val.chunked_enc = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive connections and adds 'Connection: close' header.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_CONN_CLOSE(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_CONN_CLOSE, \
|
||||
.val.conn_close = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Only respond in conservative (dumb) HTTP/1.0-compatible mode.
|
||||
* Response still use HTTP/1.1 version in header, but always close the connection after sending the response and do not use chunked encoding for the response.
|
||||
* You can also set the #MHD_R_O_HTTP_1_0_SERVER flag to force HTTP/1.0 version in the response.
|
||||
* Responses are still compatible with HTTP/1.1.
|
||||
* This option can be used to communicate with some broken client, which does not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT, \
|
||||
.val.http_1_0_compatible_strict = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Only respond in HTTP/1.0-mode.
|
||||
* Contrary to the #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT flag, the response's HTTP version will always be set to 1.0 and keep-alive connections will be used if explicitly requested by the client.
|
||||
* The 'Connection:' header will be added for both 'close' and 'keep-alive' connections.
|
||||
* Chunked encoding will not be used for the response.
|
||||
* Due to backward compatibility, responses still can be used with HTTP/1.1 clients.
|
||||
* This option can be used to emulate HTTP/1.0 server (for response part only as chunked encoding in requests (if any) is processed by MHD).
|
||||
* With this option HTTP/1.0 server is emulated (with support for 'keep-alive' connections).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_HTTP_1_0_SERVER(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_HTTP_1_0_SERVER, \
|
||||
.val.http_1_0_server = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP content length option.
|
||||
* Allow to set several 'Content-Length' headers. These headers will be used even with replies without body.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH(val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH, \
|
||||
.val.insanity_header_content_length = (val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set a function to be called once MHD is finished with the request.
|
||||
* @param term_cb the function to call,
|
||||
* NULL to not use the callback
|
||||
* @param term_cb_cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_TERMINATION_CALLBACK(term_cb,term_cb_cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_TERMINATION_CALLBACK, \
|
||||
.val.termination_callback.v_term_cb = (term_cb), \
|
||||
.val.termination_callback.v_term_cb_cls = (term_cb_cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Terminate the list of the options
|
||||
* @return the terminating object of struct MHD_ResponseOptionAndValue
|
||||
*/
|
||||
# define MHD_R_OPTION_TERMINATE() \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_END) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
#else /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
||||
MHD_NOWARN_UNUSED_FUNC_
|
||||
/**
|
||||
* Make the response object re-usable.
|
||||
* The response will not be consumed by MHD_action_from_response() and must be destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_REUSABLE (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_REUSABLE;
|
||||
opt_val.val.reusable = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable special processing of the response as body-less (with undefined body size). No automatic 'Content-Length' or 'Transfer-Encoding: chunked' headers are added when the response is used with #MHD_HTTP_STATUS_NOT_MODIFIED code or to respond to HEAD request.
|
||||
* The flag also allow to set arbitrary 'Content-Length' by #MHD_response_add_header() function.
|
||||
* This flag value can be used only with responses created without body (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic 'Content-Length' header is undesirable in response to HEAD requests.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_HEAD_ONLY_RESPONSE (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HEAD_ONLY_RESPONSE;
|
||||
opt_val.val.head_only_response = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_CHUNKED_ENC (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_CHUNKED_ENC;
|
||||
opt_val.val.chunked_enc = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive connections and adds 'Connection: close' header.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_CONN_CLOSE (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_CONN_CLOSE;
|
||||
opt_val.val.conn_close = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Only respond in conservative (dumb) HTTP/1.0-compatible mode.
|
||||
* Response still use HTTP/1.1 version in header, but always close the connection after sending the response and do not use chunked encoding for the response.
|
||||
* You can also set the #MHD_R_O_HTTP_1_0_SERVER flag to force HTTP/1.0 version in the response.
|
||||
* Responses are still compatible with HTTP/1.1.
|
||||
* This option can be used to communicate with some broken client, which does not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT;
|
||||
opt_val.val.http_1_0_compatible_strict = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Only respond in HTTP/1.0-mode.
|
||||
* Contrary to the #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT flag, the response's HTTP version will always be set to 1.0 and keep-alive connections will be used if explicitly requested by the client.
|
||||
* The 'Connection:' header will be added for both 'close' and 'keep-alive' connections.
|
||||
* Chunked encoding will not be used for the response.
|
||||
* Due to backward compatibility, responses still can be used with HTTP/1.1 clients.
|
||||
* This option can be used to emulate HTTP/1.0 server (for response part only as chunked encoding in requests (if any) is processed by MHD).
|
||||
* With this option HTTP/1.0 server is emulated (with support for 'keep-alive' connections).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_SERVER (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HTTP_1_0_SERVER;
|
||||
opt_val.val.http_1_0_server = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP content length option.
|
||||
* Allow to set several 'Content-Length' headers. These headers will be used even with replies without body.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH (
|
||||
enum MHD_Bool val
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH;
|
||||
opt_val.val.insanity_header_content_length = (val); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a function to be called once MHD is finished with the request.
|
||||
* @param term_cb the function to call,
|
||||
* NULL to not use the callback
|
||||
* @param term_cb_cls the closure for the callback
|
||||
* @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_responseOptionAndValue
|
||||
MHD_R_OPTION_TERMINATION_CALLBACK (
|
||||
MHD_RequestTerminationCallback term_cb,
|
||||
void *term_cb_cls
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_TERMINATION_CALLBACK;
|
||||
opt_val.val.termination_callback.v_term_cb = term_cb;
|
||||
opt_val.val.termination_callback.v_term_cb_cls = term_cb_cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Terminate the list of the options
|
||||
* @return the terminating object of struct MHD_ResponseOptionAndValue
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_TERMINATE (void)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_END;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
MHD_RESTORE_WARN_UNUSED_FUNC_
|
||||
#endif /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
||||
@@ -108,6 +108,7 @@ MHD_FN_PAR_NONNULL_ALL_;
|
||||
MHD_daemon_set_options (daemon, options_ptr, 1)
|
||||
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef MHD_USE_VARARG_MACROS
|
||||
MHD_NOWARN_VARIADIC_MACROS_
|
||||
# if defined(MHD_USE_COMPOUND_LITERALS) && \
|
||||
@@ -130,7 +131,7 @@ MHD_NOWARN_VARIADIC_MACROS_
|
||||
*/
|
||||
# define MHD_DAEMON_SET_OPTIONS(daemon,...) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
MHD_daemon_set_options ( \
|
||||
MHD_daemon_set_options ( \
|
||||
daemon, \
|
||||
((const struct MHD_DaemonOptionAndValue[]) \
|
||||
{__VA_ARGS__, MHD_D_OPTION_TERMINATE ()}), \
|
||||
@@ -158,7 +159,7 @@ MHD_C_DECLRATIONS_START_HERE_
|
||||
*/
|
||||
# define MHD_DAEMON_SET_OPTIONS(daemon,...) \
|
||||
MHD_NOWARN_CPP_INIT_LIST_ \
|
||||
MHD_daemon_set_options ( \
|
||||
MHD_daemon_set_options ( \
|
||||
daemon, \
|
||||
(std::vector<struct MHD_DaemonOptionAndValue> \
|
||||
{__VA_ARGS__,MHD_D_OPTION_TERMINATE ()}).data (), \
|
||||
@@ -167,6 +168,7 @@ MHD_C_DECLRATIONS_START_HERE_
|
||||
# endif
|
||||
MHD_RESTORE_WARN_VARIADIC_MACROS_
|
||||
#endif /* MHD_USE_VARARG_MACROS && MHD_USE_COMP_LIT_FUNC_PARAMS */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
/* ******************* Event loop ************************ */
|
||||
@@ -449,6 +451,7 @@ MHD_FN_PAR_NONNULL_ALL_;
|
||||
MHD_connection_set_options (connection, options_ptr, 1)
|
||||
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef MHD_USE_VARARG_MACROS
|
||||
MHD_NOWARN_VARIADIC_MACROS_
|
||||
# if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_COMP_LIT_FUNC_PARAMS \
|
||||
@@ -470,7 +473,7 @@ MHD_NOWARN_VARIADIC_MACROS_
|
||||
*/
|
||||
# define MHD_CONNECTION_SET_OPTIONS(connection,...) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
MHD_connection_set_options ( \
|
||||
MHD_connection_set_options ( \
|
||||
daemon, \
|
||||
((const struct MHD_ConnectionOptionAndValue []) \
|
||||
{__VA_ARGS__, MHD_C_OPTION_TERMINATE ()}), \
|
||||
@@ -497,7 +500,7 @@ MHD_C_DECLRATIONS_START_HERE_
|
||||
*/
|
||||
# define MHD_CONNECTION_SET_OPTIONS(daemon,...) \
|
||||
MHD_NOWARN_CPP_INIT_LIST_ \
|
||||
MHD_daemon_set_options ( \
|
||||
MHD_daemon_set_options ( \
|
||||
daemon, \
|
||||
(std::vector<struct MHD_ConnectionOptionAndValue> \
|
||||
{__VA_ARGS__,MHD_C_OPTION_TERMINATE ()}).data (), \
|
||||
@@ -506,6 +509,7 @@ MHD_C_DECLRATIONS_START_HERE_
|
||||
# endif
|
||||
MHD_RESTORE_WARN_VARIADIC_MACROS_
|
||||
#endif /* MHD_USE_VARARG_MACROS && MHD_USE_COMP_LIT_FUNC_PARAMS */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
/* **************** Request handling functions ***************** */
|
||||
@@ -1005,696 +1009,6 @@ MHD_action_from_response (struct MHD_Request *request,
|
||||
struct MHD_Response *response);
|
||||
|
||||
|
||||
/**
|
||||
* The `enum MHD_RequestTerminationCode` specifies reasons
|
||||
* why a request has been terminated (or completed).
|
||||
* @ingroup request
|
||||
*/
|
||||
enum MHD_FIXED_ENUM_MHD_SET_ MHD_RequestTerminationCode
|
||||
{
|
||||
|
||||
/**
|
||||
* The response was successfully sent.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_COMPLETED_OK = 0
|
||||
,
|
||||
/**
|
||||
* The application terminated request without response.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_BY_APP = 1
|
||||
,
|
||||
/**
|
||||
* The request is not valid according to
|
||||
* HTTP specifications.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_HTTP_PROTOCOL_ERROR = 2
|
||||
,
|
||||
/**
|
||||
* The client terminated the connection by closing the socket
|
||||
* for writing (TCP half-closed) before sending complete request;
|
||||
* MHD aborted sending the response according to RFC 2616, section 8.1.4.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_CLIENT_ABORT = 3
|
||||
,
|
||||
/**
|
||||
* Error handling the connection due to resources exhausted.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_NO_RESOURCES = 4
|
||||
,
|
||||
/**
|
||||
* We had to close the session since MHD was being shut down.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 5
|
||||
,
|
||||
/**
|
||||
* No activity on the connection for the number of seconds specified using
|
||||
* #MHD_C_OPTION_TIMEOUT().
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 6
|
||||
,
|
||||
/**
|
||||
* The connection was broken or TLS protocol error.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_CONNECTION_ERROR = 7
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional information about request termination
|
||||
*/
|
||||
union MHD_RequestTerminationDetail
|
||||
{
|
||||
/**
|
||||
* Reserved member.
|
||||
* Do not use.
|
||||
*/
|
||||
void *reserved;
|
||||
};
|
||||
|
||||
/**
|
||||
* Request termination data structure
|
||||
*/
|
||||
struct MHD_RequestTerminationData
|
||||
{
|
||||
/**
|
||||
* The code of the event
|
||||
*/
|
||||
enum MHD_RequestTerminationCode code;
|
||||
/**
|
||||
* Detailed information about termination event
|
||||
*/
|
||||
union MHD_RequestTerminationDetail details;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Signature of the callback used by MHD to notify the application
|
||||
* about completed requests.
|
||||
*
|
||||
* @param cls client-defined closure
|
||||
* @param data the details about the event
|
||||
* @param request_context request context value, as originally
|
||||
* returned by the #MHD_EarlyUriLogCallback
|
||||
* @see #MHD_R_OPTION_TERMINATION_CALLBACK()
|
||||
* @ingroup request
|
||||
*/
|
||||
typedef void
|
||||
(*MHD_RequestTerminationCallback) (void *cls,
|
||||
struct MHD_RequestTerminationData *data,
|
||||
void *request_context);
|
||||
|
||||
|
||||
/**
|
||||
* The options (parameters) for responses.
|
||||
*/
|
||||
enum MHD_FIXED_ENUM_APP_SET_ MHD_ResponseOption
|
||||
{
|
||||
/**
|
||||
* Not a real option, terminate the list of options
|
||||
*/
|
||||
MHD_R_O_END = 0
|
||||
,
|
||||
|
||||
/* = MHD Response Option enum values below are generated automatically = */
|
||||
/**
|
||||
* Make the response object reusable.
|
||||
* The response will not be consumed by MHD_action_from_response() and must
|
||||
* be destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* The parameter value must be placed to the
|
||||
* @a v_reusable member.
|
||||
*/
|
||||
MHD_R_O_REUSABLE = 20
|
||||
,
|
||||
/**
|
||||
* Enable special processing of the response as body-less (with undefined
|
||||
* body size). No automatic "Content-Length" or "Transfer-Encoding: chunked"
|
||||
* headers are added when the response is used with
|
||||
* #MHD_HTTP_STATUS_NOT_MODIFIED code or to respond to HEAD request.
|
||||
* The flag also allow to set arbitrary "Content-Length" by
|
||||
* #MHD_response_add_header() function.
|
||||
* This flag value can be used only with responses created without body
|
||||
* (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply
|
||||
* body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic "Content-Length"
|
||||
* header is undesirable in response to HEAD requests.
|
||||
* The parameter value must be placed to the
|
||||
* @a v_head_only_response member.
|
||||
*/
|
||||
MHD_R_O_HEAD_ONLY_RESPONSE = 40
|
||||
,
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* The parameter value must be placed to the
|
||||
* @a v_chunked_enc member.
|
||||
*/
|
||||
MHD_R_O_CHUNKED_ENC = 41
|
||||
,
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive
|
||||
* connections and adds "Connection: close" header.
|
||||
* The parameter value must be placed to the
|
||||
* @a v_conn_close member.
|
||||
*/
|
||||
MHD_R_O_CONN_CLOSE = 60
|
||||
,
|
||||
/**
|
||||
* Only respond in conservative (dumb) HTTP/1.0-compatible mode.
|
||||
* Response still use HTTP/1.1 version in header, but always close the
|
||||
* connection after sending the response and do not use chunked encoding for
|
||||
* the response.
|
||||
* You can also set the #MHD_R_O_HTTP_1_0_SERVER flag to force HTTP/1.0
|
||||
* version in the response.
|
||||
* Responses are still compatible with HTTP/1.1.
|
||||
* This option can be used to communicate with some broken client, which does
|
||||
* not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* The parameter value must be placed to the
|
||||
* @a v_http_1_0_compatible_strict member.
|
||||
*/
|
||||
MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT = 80
|
||||
,
|
||||
/**
|
||||
* Only respond in HTTP/1.0-mode.
|
||||
* Contrary to the #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT flag, the response's
|
||||
* HTTP version will always be set to 1.0 and keep-alive connections will be
|
||||
* used if explicitly requested by the client.
|
||||
* The "Connection:" header will be added for both "close" and "keep-alive"
|
||||
* connections.
|
||||
* Chunked encoding will not be used for the response.
|
||||
* Due to backward compatibility, responses still can be used with HTTP/1.1
|
||||
* clients.
|
||||
* This option can be used to emulate HTTP/1.0 server (for response part only
|
||||
* as chunked encoding in requests (if any) is processed by MHD).
|
||||
* With this option HTTP/1.0 server is emulated (with support for
|
||||
* "keep-alive" connections).
|
||||
* The parameter value must be placed to the
|
||||
* @a v_http_1_0_server member.
|
||||
*/
|
||||
MHD_R_O_HTTP_1_0_SERVER = 81
|
||||
,
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP
|
||||
* content length option.
|
||||
* Allow to set several "Content-Length" headers. These headers will be used
|
||||
* even with replies without body.
|
||||
* The parameter value must be placed to the
|
||||
* @a v_insanity_header_content_length member.
|
||||
*/
|
||||
MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH = 100
|
||||
,
|
||||
/**
|
||||
* Set a function to be called once MHD is finished with the request.
|
||||
* The parameter value must be placed to the
|
||||
* @a v_termination_callback member.
|
||||
*/
|
||||
MHD_R_O_TERMINATION_CALLBACK = 121
|
||||
,
|
||||
/* = MHD Response Option enum values above are generated automatically = */
|
||||
|
||||
/* * Sentinel * */
|
||||
/**
|
||||
* The sentinel value.
|
||||
* This value enforces specific underlying integer type for the enum.
|
||||
* Do not use.
|
||||
*/
|
||||
MHD_R_O_SENTINEL = 65535
|
||||
|
||||
};
|
||||
|
||||
/* = MHD Response Option structures below are generated automatically = */
|
||||
/**
|
||||
* Data for #MHD_R_O_TERMINATION_CALLBACK
|
||||
*/
|
||||
struct MHD_ResponeOptionValueTermCB
|
||||
{
|
||||
/**
|
||||
* The function to call,
|
||||
* NULL to not use the callback
|
||||
*/
|
||||
MHD_RequestTerminationCallback v_term_cb;
|
||||
/**
|
||||
* The closure for the callback
|
||||
*/
|
||||
void *v_term_cb_cls;
|
||||
};
|
||||
|
||||
/* = MHD Response Option structures above are generated automatically = */
|
||||
|
||||
/**
|
||||
* Parameters for response options
|
||||
*/
|
||||
union MHD_ResponseOptionValue
|
||||
{
|
||||
/* = MHD Response Option union members below are generated automatically = */
|
||||
/**
|
||||
* Value for #MHD_R_O_REUSABLE
|
||||
*/
|
||||
enum MHD_Bool v_reusable;
|
||||
/**
|
||||
* Value for #MHD_R_O_HEAD_ONLY_RESPONSE
|
||||
*/
|
||||
enum MHD_Bool v_head_only_response;
|
||||
/**
|
||||
* Value for #MHD_R_O_CHUNKED_ENC
|
||||
*/
|
||||
enum MHD_Bool v_chunked_enc;
|
||||
/**
|
||||
* Value for #MHD_R_O_CONN_CLOSE
|
||||
*/
|
||||
enum MHD_Bool v_conn_close;
|
||||
/**
|
||||
* Value for #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT
|
||||
*/
|
||||
enum MHD_Bool v_http_1_0_compatible_strict;
|
||||
/**
|
||||
* Value for #MHD_R_O_HTTP_1_0_SERVER
|
||||
*/
|
||||
enum MHD_Bool v_http_1_0_server;
|
||||
/**
|
||||
* Value for #MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH
|
||||
*/
|
||||
enum MHD_Bool v_insanity_header_content_length;
|
||||
/**
|
||||
* Value for #MHD_R_O_TERMINATION_CALLBACK
|
||||
*/
|
||||
struct MHD_ResponeOptionValueTermCB v_termination_callback;
|
||||
/* = MHD Response Option union members above are generated automatically = */
|
||||
};
|
||||
|
||||
/**
|
||||
* Combination of response option with parameters values
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
{
|
||||
/**
|
||||
* The response configuration option
|
||||
*/
|
||||
enum MHD_ResponseOption opt;
|
||||
/**
|
||||
* The value for the @a opt option
|
||||
*/
|
||||
union MHD_ResponseOptionValue val;
|
||||
};
|
||||
|
||||
|
||||
#if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_DESIG_NEST_INIT)
|
||||
/* = MHD Response Option macros below are generated automatically = */
|
||||
/**
|
||||
* Make the response object reusable.
|
||||
* The response will not be consumed by MHD_action_from_response() and must be
|
||||
* destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_REUSABLE(bool_val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_REUSABLE), \
|
||||
.val.v_reusable = (bool_val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Enable special processing of the response as body-less (with undefined body
|
||||
* size). No automatic "Content-Length" or "Transfer-Encoding: chunked" headers
|
||||
* are added when the response is used with #MHD_HTTP_STATUS_NOT_MODIFIED code
|
||||
* or to respond to HEAD request.
|
||||
* The flag also allow to set arbitrary "Content-Length" by
|
||||
* #MHD_response_add_header() function.
|
||||
* This flag value can be used only with responses created without body
|
||||
* (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply
|
||||
* body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic "Content-Length"
|
||||
* header is undesirable in response to HEAD requests.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_HEAD_ONLY_RESPONSE(bool_val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_HEAD_ONLY_RESPONSE), \
|
||||
.val.v_head_only_response = (bool_val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_CHUNKED_ENC(bool_val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_CHUNKED_ENC), \
|
||||
.val.v_chunked_enc = (bool_val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive
|
||||
* connections and adds "Connection: close" header.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_CONN_CLOSE(bool_val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_CONN_CLOSE), \
|
||||
.val.v_conn_close = (bool_val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Only respond in conservative (dumb) HTTP/1.0-compatible mode.
|
||||
* Response still use HTTP/1.1 version in header, but always close the
|
||||
* connection after sending the response and do not use chunked encoding for
|
||||
* the response.
|
||||
* You can also set the #MHD_R_O_HTTP_1_0_SERVER flag to force HTTP/1.0 version
|
||||
* in the response.
|
||||
* Responses are still compatible with HTTP/1.1.
|
||||
* This option can be used to communicate with some broken client, which does
|
||||
* not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT(bool_val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT), \
|
||||
.val.v_http_1_0_compatible_strict = (bool_val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Only respond in HTTP/1.0-mode.
|
||||
* Contrary to the #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT flag, the response's
|
||||
* HTTP version will always be set to 1.0 and keep-alive connections will be
|
||||
* used if explicitly requested by the client.
|
||||
* The "Connection:" header will be added for both "close" and "keep-alive"
|
||||
* connections.
|
||||
* Chunked encoding will not be used for the response.
|
||||
* Due to backward compatibility, responses still can be used with HTTP/1.1
|
||||
* clients.
|
||||
* This option can be used to emulate HTTP/1.0 server (for response part only
|
||||
* as chunked encoding in requests (if any) is processed by MHD).
|
||||
* With this option HTTP/1.0 server is emulated (with support for "keep-alive"
|
||||
* connections).
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_HTTP_1_0_SERVER(bool_val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_HTTP_1_0_SERVER), \
|
||||
.val.v_http_1_0_server = (bool_val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP
|
||||
* content length option.
|
||||
* Allow to set several "Content-Length" headers. These headers will be used
|
||||
* even with replies without body.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH(bool_val) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH), \
|
||||
.val.v_insanity_header_content_length = (bool_val) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/**
|
||||
* Set a function to be called once MHD is finished with the request.
|
||||
* @param term_cb the function to call,
|
||||
* NULL to not use the callback
|
||||
* @param term_cb_cls the closure for the callback
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
# define MHD_R_OPTION_TERMINATION_CALLBACK(term_cb,term_cb_cls) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_TERMINATION_CALLBACK), \
|
||||
.val.v_termination_callback.v_term_cb = (term_cb), \
|
||||
.val.v_termination_callback.v_term_cb_cls = (term_cb_cls) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
/* = MHD Response Option macros above are generated automatically = */
|
||||
|
||||
/**
|
||||
* Terminate the list of the options
|
||||
* @return the terminating object of struct MHD_ResponseOptionAndValue
|
||||
*/
|
||||
# define MHD_R_OPTION_TERMINATE() \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = (MHD_R_O_END) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
|
||||
#else /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
||||
MHD_NOWARN_UNUSED_FUNC_
|
||||
/* = MHD Response Option static functions below are generated automatically = */
|
||||
/**
|
||||
* Make the response object reusable.
|
||||
* The response will not be consumed by MHD_action_from_response() and must be
|
||||
* destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_REUSABLE (enum MHD_Bool bool_val)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_REUSABLE;
|
||||
opt_val.val.v_reusable = bool_val;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable special processing of the response as body-less (with undefined body
|
||||
* size). No automatic "Content-Length" or "Transfer-Encoding: chunked" headers
|
||||
* are added when the response is used with #MHD_HTTP_STATUS_NOT_MODIFIED code
|
||||
* or to respond to HEAD request.
|
||||
* The flag also allow to set arbitrary "Content-Length" by
|
||||
* #MHD_response_add_header() function.
|
||||
* This flag value can be used only with responses created without body
|
||||
* (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply
|
||||
* body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic "Content-Length"
|
||||
* header is undesirable in response to HEAD requests.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HEAD_ONLY_RESPONSE (enum MHD_Bool bool_val)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HEAD_ONLY_RESPONSE;
|
||||
opt_val.val.v_head_only_response = bool_val;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_CHUNKED_ENC (enum MHD_Bool bool_val)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_CHUNKED_ENC;
|
||||
opt_val.val.v_chunked_enc = bool_val;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive
|
||||
* connections and adds "Connection: close" header.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_CONN_CLOSE (enum MHD_Bool bool_val)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_CONN_CLOSE;
|
||||
opt_val.val.v_conn_close = bool_val;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Only respond in conservative (dumb) HTTP/1.0-compatible mode.
|
||||
* Response still use HTTP/1.1 version in header, but always close the
|
||||
* connection after sending the response and do not use chunked encoding for
|
||||
* the response.
|
||||
* You can also set the #MHD_R_O_HTTP_1_0_SERVER flag to force HTTP/1.0 version
|
||||
* in the response.
|
||||
* Responses are still compatible with HTTP/1.1.
|
||||
* This option can be used to communicate with some broken client, which does
|
||||
* not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT (enum MHD_Bool bool_val)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT;
|
||||
opt_val.val.v_http_1_0_compatible_strict = bool_val;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Only respond in HTTP/1.0-mode.
|
||||
* Contrary to the #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT flag, the response's
|
||||
* HTTP version will always be set to 1.0 and keep-alive connections will be
|
||||
* used if explicitly requested by the client.
|
||||
* The "Connection:" header will be added for both "close" and "keep-alive"
|
||||
* connections.
|
||||
* Chunked encoding will not be used for the response.
|
||||
* Due to backward compatibility, responses still can be used with HTTP/1.1
|
||||
* clients.
|
||||
* This option can be used to emulate HTTP/1.0 server (for response part only
|
||||
* as chunked encoding in requests (if any) is processed by MHD).
|
||||
* With this option HTTP/1.0 server is emulated (with support for "keep-alive"
|
||||
* connections).
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_SERVER (enum MHD_Bool bool_val)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HTTP_1_0_SERVER;
|
||||
opt_val.val.v_http_1_0_server = bool_val;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP
|
||||
* content length option.
|
||||
* Allow to set several "Content-Length" headers. These headers will be used
|
||||
* even with replies without body.
|
||||
* @param bool_val the value of the parameter
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH (enum MHD_Bool bool_val)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH;
|
||||
opt_val.val.v_insanity_header_content_length = bool_val;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a function to be called once MHD is finished with the request.
|
||||
* @param term_cb the function to call,
|
||||
* NULL to not use the callback
|
||||
* @param term_cb_cls the closure for the callback
|
||||
* @return the object of struct MHD_ResponseOptionAndValue with the requested
|
||||
* values
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_TERMINATION_CALLBACK (
|
||||
MHD_RequestTerminationCallback term_cb,
|
||||
void *term_cb_cls)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_TERMINATION_CALLBACK;
|
||||
opt_val.val.v_termination_callback.v_term_cb = term_cb;
|
||||
opt_val.val.v_termination_callback.v_term_cb_cls = term_cb_cls;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/* = MHD Response Option static functions above are generated automatically = */
|
||||
/**
|
||||
* Terminate the list of the options
|
||||
* @return the terminating object of struct MHD_ResponseOptionAndValue
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_TERMINATE (void)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_END;
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
MHD_RESTORE_WARN_UNUSED_FUNC_
|
||||
#endif /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
||||
|
||||
|
||||
/**
|
||||
* Set the requested options for the response.
|
||||
*
|
||||
@@ -1730,6 +1044,7 @@ MHD_FN_PAR_NONNULL_ALL_;
|
||||
MHD_response_set_options (response,option_ptr,1)
|
||||
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef MHD_USE_VARARG_MACROS
|
||||
MHD_NOWARN_VARIADIC_MACROS_
|
||||
# if defined(MHD_USE_COMPOUND_LITERALS) && \
|
||||
@@ -1752,7 +1067,7 @@ MHD_NOWARN_VARIADIC_MACROS_
|
||||
*/
|
||||
# define MHD_RESPONSE_SET_OPTIONS(response,...) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
MHD_response_set_options ( \
|
||||
MHD_response_set_options ( \
|
||||
response, \
|
||||
((const struct MHD_ResponseOptionAndValue[]) \
|
||||
{__VA_ARGS__, MHD_R_OPTION_TERMINATE ()}), \
|
||||
@@ -1780,7 +1095,7 @@ MHD_C_DECLRATIONS_START_HERE_
|
||||
*/
|
||||
# define MHD_RESPONSE_SET_OPTIONS(response,...) \
|
||||
MHD_NOWARN_CPP_INIT_LIST_ \
|
||||
MHD_response_set_options ( \
|
||||
MHD_response_set_options ( \
|
||||
response, \
|
||||
(std::vector<struct MHD_ResponseOptionAndValue> \
|
||||
{__VA_ARGS__,MHD_R_OPTION_TERMINATE ()}).data (), \
|
||||
@@ -1789,6 +1104,7 @@ MHD_C_DECLRATIONS_START_HERE_
|
||||
# endif
|
||||
MHD_RESTORE_WARN_VARIADIC_MACROS_
|
||||
#endif /* MHD_USE_VARARG_MACROS && MHD_USE_COMP_LIT_FUNC_PARAMS */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
MHD_C_DECLRATIONS_START_HERE_
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
/* While we generally would like users to use a configure-driven
|
||||
build process which detects which headers are present and
|
||||
@@ -91,7 +92,7 @@ typedef SOCKET MHD_socket;
|
||||
#ifdef __GNUC__
|
||||
# define MHD_GNUC_MINV(major,minor) \
|
||||
((__GNUC__ > (major)) || \
|
||||
((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor + 0))))
|
||||
((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor+0))))
|
||||
#else /* ! __GNUC__ */
|
||||
# define MHD_GNUC_MINV(major,minor) (0)
|
||||
#endif /* ! __GNUC__ */
|
||||
@@ -99,13 +100,13 @@ typedef SOCKET MHD_socket;
|
||||
#ifdef __clang__
|
||||
# define MHD_CLANG_MINV(major,minor) \
|
||||
((__clang_major__ > (major)) || \
|
||||
((__clang_major__ == (major)) && (__clang_minor__ >= (minor + 0))))
|
||||
((__clang_major__ == (major)) && (__clang_minor__ >= (minor+0))))
|
||||
#else /* ! __GNUC__ */
|
||||
# define MHD_CLANG_MINV(major,minor) (0)
|
||||
#endif /* ! __GNUC__ */
|
||||
|
||||
#if defined(_MSC_FULL_VER)
|
||||
# define MHD_MSC_MINV(version) (_MSC_VER >= (version + 0))
|
||||
# define MHD_MSC_MINV(version) (_MSC_VER >= (version+0))
|
||||
# if defined(_MSC_FULL_VER) \
|
||||
&& (! defined(__STDC__) || defined(_MSC_EXTENSIONS))
|
||||
/* Visual C with extensions */
|
||||
@@ -127,10 +128,10 @@ typedef SOCKET MHD_socket;
|
||||
#ifndef __cplusplus
|
||||
# define MHD_CXX_MINV(version) (0)
|
||||
#elif ! defined(_MSC_FULL_VER) || ! defined(_MSVC_LANG)
|
||||
# define MHD_CXX_MINV(version) ((__cplusplus + 0) >= version)
|
||||
# define MHD_CXX_MINV(version) ((__cplusplus+0) >= version)
|
||||
#else
|
||||
# define MHD_CXX_MINV(version) \
|
||||
((__cplusplus + 0) >= version) || ((_MSVC_LANG + 0) >= version)
|
||||
((__cplusplus+0) >= version) || ((_MSVC_LANG+0) >= version)
|
||||
#endif
|
||||
|
||||
/* Use compound literals? */
|
||||
@@ -320,7 +321,7 @@ typedef SOCKET MHD_socket;
|
||||
_Pragma(MHD_MACRO_STR_(GCC diagnostic ignored MHD_MACRO_STR__(warn)))
|
||||
# ifdef MHD_USE_VARARG_MACROS_EXT
|
||||
# define MHD_NOWARN_VARIADIC_MACROS_ \
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wvariadic - macros)
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wvariadic-macros)
|
||||
# define MHD_RESTORE_WARN_VARIADIC_MACROS_ MHD_WARN_POP_
|
||||
# endif
|
||||
# ifdef MHD_USE_COMPOUND_LITERALS_EXT
|
||||
@@ -328,7 +329,7 @@ typedef SOCKET MHD_socket;
|
||||
# define MHD_RESTORE_WARN_COMPOUND_LITERALS_ /* empty */
|
||||
# endif
|
||||
# define MHD_NOWARN_UNUSED_FUNC_ \
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wunused - function)
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wunused-function)
|
||||
# define MHD_RESTORE_WARN_UNUSED_FUNC_ MHD_WARN_POP_
|
||||
# elif MHD_CLANG_MINV (3,1)
|
||||
# define MHD_WARN_PUSH_ _Pragma("clang diagnostic push")
|
||||
@@ -338,26 +339,26 @@ typedef SOCKET MHD_socket;
|
||||
# ifdef MHD_USE_VARARG_MACROS_EXT
|
||||
# define MHD_NOWARN_VARIADIC_MACROS_ \
|
||||
MHD_WARN_PUSH_ \
|
||||
MHD_WARN_INGORE_ (-Wvariadic - macros) \
|
||||
MHD_WARN_INGORE_ (-Wc++ 98 - compat - pedantic)
|
||||
MHD_WARN_INGORE_ (-Wvariadic-macros) \
|
||||
MHD_WARN_INGORE_ (-Wc++98-compat-pedantic)
|
||||
# define MHD_RESTORE_WARN_VARIADIC_MACROS_ MHD_WARN_POP_
|
||||
# else /* ! MHD_USE_VARARG_MACROS_EXT */
|
||||
# define MHD_NOWARN_VARIADIC_MACROS_ \
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wc++ 98 - compat - pedantic)
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wc++98-compat-pedantic)
|
||||
# define MHD_RESTORE_WARN_VARIADIC_MACROS_ MHD_WARN_POP_
|
||||
# endif
|
||||
# ifdef MHD_USE_CPP_INIT_LIST
|
||||
# define MHD_NOWARN_CPP_INIT_LIST_ \
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wc++ 98 - compat)
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wc++98-compat)
|
||||
# define MHD_RESTORE_WARN_CPP_INIT_LIST_ MHD_WARN_POP_
|
||||
# endif
|
||||
# ifdef MHD_USE_COMPOUND_LITERALS_EXT
|
||||
# define MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wc99 - extensions)
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wc99-extensions)
|
||||
# define MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_WARN_POP_
|
||||
# endif
|
||||
# define MHD_NOWARN_UNUSED_FUNC_ \
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wunused - function)
|
||||
MHD_WARN_PUSH_ MHD_WARN_INGORE_ (-Wunused-function)
|
||||
# define MHD_RESTORE_WARN_UNUSED_FUNC_ MHD_WARN_POP_
|
||||
# elif MHD_MSC_MINV (1500)
|
||||
# define MHD_WARN_PUSH_ __pragma(warning(push))
|
||||
|
||||
@@ -2992,3 +2992,112 @@ typedef void
|
||||
const struct MHD_StreamNotificationData *data);
|
||||
|
||||
#include "microhttpd2_generated_daemon_options.h"
|
||||
|
||||
|
||||
/**
|
||||
* The `enum MHD_RequestTerminationCode` specifies reasons
|
||||
* why a request has been terminated (or completed).
|
||||
* @ingroup request
|
||||
*/
|
||||
enum MHD_FIXED_ENUM_MHD_SET_ MHD_RequestTerminationCode
|
||||
{
|
||||
|
||||
/**
|
||||
* The response was successfully sent.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_COMPLETED_OK = 0
|
||||
,
|
||||
/**
|
||||
* The application terminated request without response.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_BY_APP = 1
|
||||
,
|
||||
/**
|
||||
* The request is not valid according to
|
||||
* HTTP specifications.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_HTTP_PROTOCOL_ERROR = 2
|
||||
,
|
||||
/**
|
||||
* The client terminated the connection by closing the socket
|
||||
* for writing (TCP half-closed) before sending complete request;
|
||||
* MHD aborted sending the response according to RFC 2616, section 8.1.4.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_CLIENT_ABORT = 3
|
||||
,
|
||||
/**
|
||||
* Error handling the connection due to resources exhausted.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_NO_RESOURCES = 4
|
||||
,
|
||||
/**
|
||||
* We had to close the session since MHD was being shut down.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 5
|
||||
,
|
||||
/**
|
||||
* No activity on the connection for the number of seconds specified using
|
||||
* #MHD_C_OPTION_TIMEOUT().
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 6
|
||||
,
|
||||
/**
|
||||
* The connection was broken or TLS protocol error.
|
||||
* @ingroup request
|
||||
*/
|
||||
MHD_REQUEST_TERMINATED_CONNECTION_ERROR = 7
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional information about request termination
|
||||
*/
|
||||
union MHD_RequestTerminationDetail
|
||||
{
|
||||
/**
|
||||
* Reserved member.
|
||||
* Do not use.
|
||||
*/
|
||||
void *reserved;
|
||||
};
|
||||
|
||||
/**
|
||||
* Request termination data structure
|
||||
*/
|
||||
struct MHD_RequestTerminationData
|
||||
{
|
||||
/**
|
||||
* The code of the event
|
||||
*/
|
||||
enum MHD_RequestTerminationCode code;
|
||||
/**
|
||||
* Detailed information about termination event
|
||||
*/
|
||||
union MHD_RequestTerminationDetail details;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Signature of the callback used by MHD to notify the application
|
||||
* about completed requests.
|
||||
*
|
||||
* @param cls client-defined closure
|
||||
* @param data the details about the event
|
||||
* @param request_context request context value, as originally
|
||||
* returned by the #MHD_EarlyUriLogCallback
|
||||
* @see #MHD_R_OPTION_TERMINATION_CALLBACK()
|
||||
* @ingroup request
|
||||
*/
|
||||
typedef void
|
||||
(*MHD_RequestTerminationCallback) (void *cls,
|
||||
struct MHD_RequestTerminationData *data,
|
||||
void *request_context);
|
||||
|
||||
|
||||
#include "microhttpd2_generated_response_options.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/**
|
||||
* @file daemon-options-generator.c
|
||||
* @file options-generator.c
|
||||
* @brief Generates code based on JSON-converted Recutils database
|
||||
* @author Christian Grothoff
|
||||
*/
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
static FILE *f;
|
||||
|
||||
static char *category;
|
||||
|
||||
typedef void
|
||||
(*Callback) (const char *name,
|
||||
@@ -138,9 +139,13 @@ indent (char *pfx,
|
||||
const char *input)
|
||||
{
|
||||
char *ret = strdup (input);
|
||||
char *xfx = strdup (pfx);
|
||||
char *off;
|
||||
size_t pos = 0;
|
||||
|
||||
while ( (strlen (xfx) > 0) &&
|
||||
(isspace (xfx[strlen (xfx) - 1])) )
|
||||
xfx[strlen (xfx) - 1] = '\0';
|
||||
while (NULL != (off = strchr (ret + pos, '\n')))
|
||||
{
|
||||
char *tmp;
|
||||
@@ -149,7 +154,9 @@ indent (char *pfx,
|
||||
"%.*s\n%s%s",
|
||||
(int) (off - ret),
|
||||
ret,
|
||||
pfx,
|
||||
(off[1] == '\n')
|
||||
? xfx
|
||||
: pfx,
|
||||
off + 1);
|
||||
pos = (off - ret) + strlen (pfx) + 1;
|
||||
free (ret);
|
||||
@@ -170,6 +177,16 @@ uppercase (const char *input)
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
capitalize (const char *input)
|
||||
{
|
||||
char *ret = strdup (input);
|
||||
|
||||
ret[0] = toupper (ret[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
lowercase (const char *input)
|
||||
{
|
||||
@@ -190,8 +207,9 @@ dump_enum (const char *name,
|
||||
json_t *args,
|
||||
json_t *descs)
|
||||
{
|
||||
printf (" /**\n * %s\n */\n MHD_D_O_%s = %u\n ,\n\n",
|
||||
printf (" /**\n * %s\n */\n MHD_%c_O_%s = %u\n ,\n\n",
|
||||
indent (" * ", comment),
|
||||
(char) toupper (*category),
|
||||
uppercase (name),
|
||||
value);
|
||||
}
|
||||
@@ -223,7 +241,8 @@ dump_union_members (const char *name,
|
||||
if (1 >= json_array_size (args))
|
||||
return;
|
||||
|
||||
printf ("/**\n * Data for #MHD_D_O_%s\n */\n%s\n{\n",
|
||||
printf ("/**\n * Data for #MHD_%c_O_%s\n */\n%s\n{\n",
|
||||
(char) toupper (*category),
|
||||
uppercase (name),
|
||||
type);
|
||||
for (unsigned int i = 0; i<json_array_size (args); i++)
|
||||
@@ -259,7 +278,10 @@ dump_union (const char *name,
|
||||
xcomment = json_string_value (json_array_get (descs,
|
||||
0));
|
||||
fprintf (f,
|
||||
" /**\n * Value for #MHD_D_O_%s.%s%s\n */\n",
|
||||
" /**\n"
|
||||
" * Value for #MHD_%c_O_%s.%s%s\n"
|
||||
" */\n",
|
||||
(char) toupper (*category),
|
||||
uppercase (name),
|
||||
NULL != xcomment
|
||||
? "\n * "
|
||||
@@ -281,7 +303,7 @@ dump_union (const char *name,
|
||||
const char *vn = var_name (arg);
|
||||
|
||||
fprintf (f,
|
||||
" %.*s %s;\n",
|
||||
" %.*s%s;\n",
|
||||
(int) (vn - arg),
|
||||
arg,
|
||||
lowercase (name));
|
||||
@@ -301,8 +323,9 @@ dump_struct (const char *name,
|
||||
json_t *descs)
|
||||
{
|
||||
if (NULL != conditional)
|
||||
printf ("#ifdef HAVE_%s",
|
||||
uppercase (conditional));
|
||||
fprintf (f,
|
||||
"#ifdef HAVE_%s",
|
||||
uppercase (conditional));
|
||||
dump_union (name,
|
||||
value,
|
||||
comment,
|
||||
@@ -311,8 +334,10 @@ dump_struct (const char *name,
|
||||
args,
|
||||
descs);
|
||||
if (NULL != conditional)
|
||||
printf ("#endif\n");
|
||||
printf ("\n");
|
||||
fprintf (f,
|
||||
"#endif\n");
|
||||
fprintf (f,
|
||||
"\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -346,7 +371,8 @@ dump_option_macros (const char *name,
|
||||
if (0 == json_array_size (descs))
|
||||
printf (" * @param val the value of the parameter");
|
||||
printf (" * @return structure with the requested setting\n */\n");
|
||||
printf ("# define MHD_D_OPTION_%s(",
|
||||
printf ("# define MHD_%c_OPTION_%s(",
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == json_array_size (args))
|
||||
printf ("val");
|
||||
@@ -363,9 +389,11 @@ dump_option_macros (const char *name,
|
||||
}
|
||||
printf (") \\\n"
|
||||
" MHD_NOWARN_COMPOUND_LITERALS_ \\\n"
|
||||
" (const struct MHD_DaemonOptionAndValue) \\\n"
|
||||
" (const struct MHD_%sOptionAndValue) \\\n"
|
||||
" { \\\n"
|
||||
" .opt = MHD_D_O_%s, \\\n",
|
||||
" .opt = MHD_%c_O_%s, \\\n",
|
||||
capitalize (category),
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == json_array_size (args))
|
||||
printf (" .val.%s = (val) \\\n",
|
||||
@@ -396,7 +424,7 @@ dump_option_macros (const char *name,
|
||||
}
|
||||
|
||||
printf (" } \\\n"
|
||||
" MHD_RESTORE_WARN_COMPOUND_LITERALS_\n\n");
|
||||
" MHD_RESTORE_WARN_COMPOUND_LITERALS_\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -413,6 +441,7 @@ dump_option_static_functions (const char *name,
|
||||
json_t *pos;
|
||||
|
||||
printf (
|
||||
"\n"
|
||||
"/**\n * %s\n",
|
||||
indent (" * ", comment));
|
||||
json_array_foreach (descs, off, pos)
|
||||
@@ -430,11 +459,13 @@ dump_option_static_functions (const char *name,
|
||||
if (0 == json_array_size (descs))
|
||||
printf (" * @param val the value of the parameter");
|
||||
printf (" * @return structure with the requested setting\n */\n");
|
||||
printf ("static MHD_INLINE struct MHD_DaemonOptionAndValue\n"
|
||||
"MHD_D_OPTION_%s(",
|
||||
printf ("static MHD_INLINE struct MHD_%sOptionAndValue\n"
|
||||
"MHD_%c_OPTION_%s (\n",
|
||||
category,
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == json_array_size (args))
|
||||
printf ("%s val",
|
||||
printf (" %s val",
|
||||
NULL != type
|
||||
? type
|
||||
: json_string_value (
|
||||
@@ -450,14 +481,20 @@ dump_option_static_functions (const char *name,
|
||||
const char *vn
|
||||
= var_name (arg);
|
||||
if (0 != i)
|
||||
printf (", ");
|
||||
printf ("%.*s %s",
|
||||
printf (",\n");
|
||||
printf (" %.*s%s",
|
||||
(int) (vn - arg),
|
||||
arg,
|
||||
vn);
|
||||
}
|
||||
printf (
|
||||
")\n{\n struct MHD_DaemonOptionAndValue opt_val;\n\n opt_val.opt = MHD_D_O_%s;\n",
|
||||
"\n"
|
||||
" )\n"
|
||||
"{\n"
|
||||
" struct MHD_%sOptionAndValue opt_val;\n\n"
|
||||
" opt_val.opt = MHD_%c_O_%s;\n",
|
||||
capitalize (category),
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == json_array_size (args))
|
||||
printf (" opt_val.val.%s = (val); \\\n",
|
||||
@@ -514,14 +551,17 @@ dump_option_documentation_functions (const char *name,
|
||||
if (0 == json_array_size (descs))
|
||||
fprintf (f, " * @param val the value of the parameter");
|
||||
fprintf (f, " * @return structure with the requested setting\n */\n");
|
||||
fprintf (f,"struct MHD_DaemonOptionAndValue\n"
|
||||
"MHD_D_OPTION_%s(",
|
||||
fprintf (f,"struct MHD_%sOptionAndValue\n"
|
||||
"MHD_%c_OPTION_%s (\n",
|
||||
capitalize (category),
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == json_array_size (args))
|
||||
fprintf (f, "%s val",
|
||||
fprintf (f,
|
||||
" %s val",
|
||||
NULL != type
|
||||
? type
|
||||
: json_string_value (
|
||||
? type
|
||||
: json_string_value (
|
||||
json_array_get (args,
|
||||
0)));
|
||||
else
|
||||
@@ -534,14 +574,15 @@ dump_option_documentation_functions (const char *name,
|
||||
const char *vn
|
||||
= var_name (arg);
|
||||
if (0 != i)
|
||||
fprintf (f, ", ");
|
||||
fprintf (f, "%.*s %s",
|
||||
fprintf (f, ",\n");
|
||||
fprintf (f,
|
||||
" %.*s%s",
|
||||
(int) (vn - arg),
|
||||
arg,
|
||||
vn);
|
||||
}
|
||||
fprintf (f,
|
||||
");\n\n");
|
||||
"\n );\n\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -559,11 +600,13 @@ dump_option_set_switch (const char *name,
|
||||
"#ifdef HAVE_%s",
|
||||
uppercase (conditional));
|
||||
fprintf (f,
|
||||
" case MHD_D_OPTION_%s:\n",
|
||||
" case MHD_%c_OPTION_%s:\n",
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == json_array_size (args))
|
||||
fprintf (f,
|
||||
" daemon->settings.%s = option->val.%s;\n",
|
||||
" %s->settings.%s = option->val.%s;\n",
|
||||
category,
|
||||
lowercase (name),
|
||||
lowercase (name));
|
||||
else
|
||||
@@ -576,14 +619,16 @@ dump_option_set_switch (const char *name,
|
||||
|
||||
if (1 < json_array_size (args))
|
||||
fprintf (f,
|
||||
" daemon->settings.%s.v_%s = option->val.%s.v_%s;\n",
|
||||
" %s->settings.%s.v_%s = option->val.%s.v_%s;\n",
|
||||
category,
|
||||
lowercase (name),
|
||||
vn,
|
||||
lowercase (name),
|
||||
vn);
|
||||
else
|
||||
fprintf (f,
|
||||
" daemon->settings.%s = option->val.%s;\n",
|
||||
" %s->settings.%s = option->val.%s;\n",
|
||||
category,
|
||||
lowercase (name),
|
||||
lowercase (name));
|
||||
}
|
||||
@@ -596,157 +641,272 @@ dump_option_set_switch (const char *name,
|
||||
|
||||
|
||||
int
|
||||
main ()
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
json_t *j;
|
||||
json_error_t err;
|
||||
|
||||
j = json_load_file ("d_options.json", 0, &err);
|
||||
if (NULL == j)
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to parse d_options.json: %s at %d:%d\n",
|
||||
err.text,
|
||||
err.line,
|
||||
err.column);
|
||||
return 2;
|
||||
"Category argument required\n");
|
||||
return 3;
|
||||
}
|
||||
category = argv[1];
|
||||
|
||||
{
|
||||
char *fn;
|
||||
|
||||
asprintf (&fn,
|
||||
"%c_options.json",
|
||||
*category);
|
||||
j = json_load_file (fn, 0, &err);
|
||||
if (NULL == j)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to parse %s: %s at %d:%d\n",
|
||||
fn,
|
||||
err.text,
|
||||
err.line,
|
||||
err.column);
|
||||
free (fn);
|
||||
return 2;
|
||||
}
|
||||
free (fn);
|
||||
}
|
||||
iterate (j,
|
||||
&check);
|
||||
|
||||
/* Generate enum MHD_DaemonOption */
|
||||
printf (
|
||||
"/**\n * The options (parameters) for MHD daemon\n */\nenum MHD_FIXED_ENUM_APP_SET_ MHD_DaemonOption\n{");
|
||||
printf (
|
||||
"/**\n * Not a real option.\n * Should not be used directly.\n * This value indicates the end of the list of the options.\n */\n MHD_D_O_END = 0\n ,\n\n");
|
||||
/* Generate enum MHD_${CATEGORY}Option */
|
||||
printf ("/**\n"
|
||||
" * The options (parameters) for MHD %s\n"
|
||||
" */\n"
|
||||
"enum MHD_FIXED_ENUM_APP_SET_ MHD_%sOption\n"
|
||||
"{",
|
||||
category,
|
||||
capitalize (category));
|
||||
printf (" /**\n"
|
||||
" * Not a real option.\n"
|
||||
" * Should not be used directly.\n"
|
||||
" * This value indicates the end of the list of the options.\n"
|
||||
" */\n"
|
||||
" MHD_%c_O_END = 0\n"
|
||||
" ,\n\n",
|
||||
(char) toupper (*category));
|
||||
iterate (j,
|
||||
&dump_enum);
|
||||
printf (
|
||||
" /**\n * The sentinel value.\n * This value enforces specific underlying integer type for the enum.\n * Do not use.\n */\n MHD_D_O_SENTINEL = 65535\n\n");
|
||||
printf (" /**\n"
|
||||
" * The sentinel value.\n"
|
||||
" * This value enforces specific underlying integer type for the enum.\n"
|
||||
" * Do not use.\n"
|
||||
" */\n"
|
||||
" MHD_%c_O_SENTINEL = 65535\n\n",
|
||||
(char) toupper (*category));
|
||||
printf ("};\n\n");
|
||||
iterate (j,
|
||||
&dump_union_members);
|
||||
|
||||
/* Generate union MHD_DaemonOptionValue */
|
||||
printf (
|
||||
"/**\n * Parameters for MHD daemon options\n */\nunion MHD_DaemonOptionValue\n{\n");
|
||||
/* Generate union MHD_${CATEGORY}OptionValue */
|
||||
printf ("/**\n"
|
||||
" * Parameters for MHD %s options\n"
|
||||
" */\n"
|
||||
"union MHD_%sOptionValue\n"
|
||||
"{\n",
|
||||
category,
|
||||
capitalize (category));
|
||||
f = stdout;
|
||||
iterate (j,
|
||||
&dump_union);
|
||||
f = NULL;
|
||||
printf ("};\n\n");
|
||||
|
||||
printf (
|
||||
"\n\nstruct MHD_DaemonOptionAndValue\n{\n /**\n * The daemon configuration option\n */\n enum MHD_DaemonOption opt;\n /**\n * The value for the @a opt option\n */\n union MHD_DaemonOptionValue val;\n};\n\n");
|
||||
|
||||
|
||||
printf ("\n"
|
||||
"struct MHD_%sOptionAndValue\n"
|
||||
"{\n"
|
||||
" /**\n"
|
||||
" * The %s configuration option\n"
|
||||
" */\n"
|
||||
" enum MHD_%sOption opt;\n\n"
|
||||
" /**\n"
|
||||
" * The value for the @a opt option\n"
|
||||
" */\n"
|
||||
" union MHD_%sOptionValue val;\n"
|
||||
"};\n\n",
|
||||
capitalize (category),
|
||||
category,
|
||||
capitalize (category),
|
||||
capitalize (category));
|
||||
printf (
|
||||
"#if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_DESIG_NEST_INIT)\n");
|
||||
iterate (j,
|
||||
&dump_option_macros);
|
||||
printf (
|
||||
"/**\n * Terminate the list of the options\n * @return the terminating object of struct MHD_DaemonOptionAndValue\n */\n# define MHD_D_OPTION_TERMINATE() \\\n MHD_NOWARN_COMPOUND_LITERALS_ \\\n (const struct MHD_DaemonOptionAndValue) \\\n { \\\n .opt = (MHD_D_O_END) \\\n } \\\n MHD_RESTORE_WARN_COMPOUND_LITERALS_\n\n");
|
||||
"\n"
|
||||
"/**\n"
|
||||
" * Terminate the list of the options\n"
|
||||
" * @return the terminating object of struct MHD_%sOptionAndValue\n"
|
||||
" */\n"
|
||||
"# define MHD_%c_OPTION_TERMINATE() \\\n"
|
||||
" MHD_NOWARN_COMPOUND_LITERALS_ \\\n"
|
||||
" (const struct MHD_%sOptionAndValue) \\\n"
|
||||
" { \\\n"
|
||||
" .opt = (MHD_%c_O_END) \\\n"
|
||||
" } \\\n"
|
||||
" MHD_RESTORE_WARN_COMPOUND_LITERALS_\n\n",
|
||||
capitalize (category),
|
||||
(char) toupper (*category),
|
||||
capitalize (category),
|
||||
(char) toupper (*category));
|
||||
|
||||
printf (
|
||||
"#else /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */\n");
|
||||
printf ("MHD_NOWARN_UNUSED_FUNC_");
|
||||
iterate (j, &dump_option_static_functions);
|
||||
printf (
|
||||
"/**\n * Terminate the list of the options\n * @return the terminating object of struct MHD_DaemonOptionAndValue\n */\nstatic MHD_INLINE struct MHD_DaemonOptionAndValue\nMHD_D_OPTION_TERMINATE (void)\n{\n struct MHD_DaemonOptionAndValue opt_val;\n\n opt_val.opt = MHD_D_O_END;\n\n return opt_val;\n}\n\n");
|
||||
printf ("\n/**\n"
|
||||
" * Terminate the list of the options\n"
|
||||
" * @return the terminating object of struct MHD_%sOptionAndValue\n"
|
||||
" */\n"
|
||||
"static MHD_INLINE struct MHD_%sOptionAndValue\n"
|
||||
"MHD_%c_OPTION_TERMINATE (void)\n"
|
||||
"{\n"
|
||||
" struct MHD_%sOptionAndValue opt_val;\n\n"
|
||||
" opt_val.opt = MHD_%c_O_END;\n\n"
|
||||
" return opt_val;\n"
|
||||
"}\n\n\n",
|
||||
capitalize (category),
|
||||
capitalize (category),
|
||||
(char) toupper (*category),
|
||||
capitalize (category),
|
||||
(char) toupper (*category));
|
||||
|
||||
printf ("MHD_RESTORE_WARN_UNUSED_FUNC_\n");
|
||||
printf (
|
||||
"#endif /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */\n");
|
||||
|
||||
|
||||
(void) unlink ("microhttpd2_inline_documentation.h.in");
|
||||
f = fopen ("microhttpd2_inline_documentation.h.in", "w");
|
||||
if (NULL == f)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to open `microhttpd2_inline_documentation.h.in'\n");
|
||||
return 2;
|
||||
char *doc_in;
|
||||
|
||||
asprintf (&doc_in,
|
||||
"microhttpd2_inline_%s_documentation.h.in",
|
||||
category);
|
||||
(void) unlink (doc_in);
|
||||
f = fopen (doc_in, "w");
|
||||
if (NULL == f)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to open `%s'\n",
|
||||
doc_in);
|
||||
return 2;
|
||||
}
|
||||
fprintf (f,
|
||||
"/* Beginning of generated code documenting how to use options.\n"
|
||||
" You should treat the following functions *as if* they were\n"
|
||||
" part of the header/API. The actual declarations are more\n"
|
||||
" complex, so these here are just for documentation!\n"
|
||||
" We do not actually *build* this code... */\n"
|
||||
"#if 0\n\n");
|
||||
iterate (j,
|
||||
&dump_option_documentation_functions);
|
||||
fprintf (f,
|
||||
"/* End of generated code documenting how to use options */\n#endif\n\n");
|
||||
fclose (f);
|
||||
chmod (doc_in, S_IRUSR | S_IRGRP | S_IROTH);
|
||||
}
|
||||
fprintf (f,
|
||||
"/* Beginning of generated code documenting how to use options.\n"
|
||||
" You should treat the following functions *as if* they were\n"
|
||||
" part of the header/API. The actual declarations are more\n"
|
||||
" complex, so these here are just for documentation!\n"
|
||||
" We do not actually *build* this code... */\n"
|
||||
"#if 0\n\n");
|
||||
iterate (j,
|
||||
&dump_option_documentation_functions);
|
||||
fprintf (f,
|
||||
"/* End of generated code documenting how to use options */\n#endif\n\n");
|
||||
fclose (f);
|
||||
chmod ("microhttpd2_inline_documentation.h.in", S_IRUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
|
||||
(void) unlink ("../lib/daemon_set_options.c");
|
||||
f = fopen ("../lib/daemon_set_options.c", "w");
|
||||
if (NULL == f)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to open `../lib/daemon_set_options.c'\n");
|
||||
return 2;
|
||||
char *so_c;
|
||||
|
||||
asprintf (&so_c,
|
||||
"../mhd2/%s_set_options.c",
|
||||
category);
|
||||
(void) unlink (so_c);
|
||||
f = fopen (so_c, "w");
|
||||
if (NULL == f)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to open `%s'\n",
|
||||
so_c);
|
||||
return 2;
|
||||
}
|
||||
fprintf (f,
|
||||
"/* This is generated code, it is still under LGPLv3+.\n"
|
||||
" Do not edit directly! */\n"
|
||||
"/* *INDENT-OFF* */\n"
|
||||
"/**\n"
|
||||
"/* @file %s_set_options.c\n"
|
||||
"/* @author %s-options-generator.c\n"
|
||||
" */\n\n"
|
||||
"#include \"microhttpd2.h\"\n"
|
||||
"#include \"internal.h\"\n\n"
|
||||
"enum MHD_StatusCode\n"
|
||||
"MHD_%s_set_options (\n"
|
||||
" struct MHD_%s *%s,\n"
|
||||
" const struct MHD_%sOptionAndValue *options,\n"
|
||||
" size_t options_max_num)\n"
|
||||
"{\n",
|
||||
category,
|
||||
category,
|
||||
category,
|
||||
capitalize (category),
|
||||
category,
|
||||
capitalize (category));
|
||||
fprintf (f,
|
||||
" for (size_t i=0;i<options_max_num;i++)\n"
|
||||
" {\n"
|
||||
" switch (options[i].opt) {\n");
|
||||
iterate (j,
|
||||
&dump_option_set_switch);
|
||||
fprintf (f,
|
||||
" }\n"
|
||||
" return MHD_SC_OPTION_UNSUPPORTED;\n"
|
||||
" }\n"
|
||||
" return MHD_SC_OK;\n");
|
||||
fprintf (f,
|
||||
"}\n");
|
||||
|
||||
fclose (f);
|
||||
chmod (so_c, S_IRUSR | S_IRGRP | S_IROTH);
|
||||
free (so_c);
|
||||
}
|
||||
fprintf (f,
|
||||
"/* This is generated code, it is still under LGPLv3+.\n"
|
||||
" Do not edit directly! */\n"
|
||||
"/**\n"
|
||||
"/* @file daemon_set_options.c\n"
|
||||
"/* @author daemon-options-generator.c\n"
|
||||
" */\n\n"
|
||||
"#include \"microhttpd2.h\"\n"
|
||||
"#include \"internal.h\"\n\n"
|
||||
"enum MHD_StatusCode\n"
|
||||
"MHD_daemon_set_options (\n"
|
||||
" struct MHD_Daemon *daemon,\n"
|
||||
" const struct MHD_DaemonOptionAndValue *options,\n"
|
||||
" size_t options_max_num)\n"
|
||||
"{\n");
|
||||
fprintf (f,
|
||||
" for (size_t i=0;i<options_max_num;i++)\n"
|
||||
" {\n"
|
||||
" switch (options[i].opt) {\n");
|
||||
iterate (j,
|
||||
&dump_option_set_switch);
|
||||
fprintf (f,
|
||||
" }\n"
|
||||
" return MHD_SC_OPTION_UNSUPPORTED;\n"
|
||||
" }\n"
|
||||
" return MHD_SC_OK;\n");
|
||||
fprintf (f,
|
||||
"}\n");
|
||||
|
||||
fclose (f);
|
||||
chmod ("../lib/daemon_set_options.c", S_IRUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
|
||||
(void) unlink ("../lib/daemon_options.h");
|
||||
f = fopen ("../lib/daemon_options.h", "w");
|
||||
if (NULL == f)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to open `../lib/daemon_options.h'\n");
|
||||
return 2;
|
||||
char *do_h;
|
||||
|
||||
asprintf (&do_h,
|
||||
"../mhd2/%s_options.h",
|
||||
category);
|
||||
(void) unlink (do_h);
|
||||
f = fopen (do_h, "w");
|
||||
if (NULL == f)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to open `%s'\n",
|
||||
do_h);
|
||||
return 2;
|
||||
}
|
||||
fprintf (f,
|
||||
"/* This is generated code, it is still under LGPLv3+.\n"
|
||||
" Do not edit directly! */\n"
|
||||
"/* *INDENT-OFF* */\n"
|
||||
"/**\n"
|
||||
"/* @file %s_options.h\n"
|
||||
"/* @author %s-options-generator.c\n"
|
||||
" */\n\n"
|
||||
"#include \"microhttpd2.h\"\n"
|
||||
"#include \"internal.h\"\n\n"
|
||||
"struct %sOptions {\n",
|
||||
category,
|
||||
category,
|
||||
capitalize (category));
|
||||
iterate (j,
|
||||
&dump_struct);
|
||||
fprintf (f,
|
||||
"};\n");
|
||||
fclose (f);
|
||||
chmod (do_h, S_IRUSR | S_IRGRP | S_IROTH);
|
||||
free (do_h);
|
||||
}
|
||||
fprintf (f,
|
||||
"/* This is generated code, it is still under LGPLv3+.\n"
|
||||
" Do not edit directly! */\n"
|
||||
"/**\n"
|
||||
"/* @file daemon_options.h\n"
|
||||
"/* @author daemon-options-generator.c\n"
|
||||
" */\n\n"
|
||||
"#include \"microhttpd2.h\"\n"
|
||||
"#include \"internal.h\"\n\n"
|
||||
"struct DaemonOptions {\n");
|
||||
iterate (j,
|
||||
&dump_struct);
|
||||
fprintf (f,
|
||||
"};\n");
|
||||
fclose (f);
|
||||
chmod ("../lib/daemon_options.h", S_IRUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
|
||||
json_decref (j);
|
||||
@@ -29,11 +29,11 @@ Comment: Make the response object re-usable.
|
||||
Name: HEAD_ONLY_RESPONSE
|
||||
Value: 40
|
||||
Type: enum MHD_Bool
|
||||
Comment: Enable special processing of the response as body-less (with undefined body size). No automatic "Content-Length" or "Transfer-Encoding: chunked" headers are added when the response is used with #MHD_HTTP_STATUS_NOT_MODIFIED code or to respond to HEAD request.
|
||||
+ The flag also allow to set arbitrary "Content-Length" by #MHD_response_add_header() function.
|
||||
Comment: Enable special processing of the response as body-less (with undefined body size). No automatic 'Content-Length' or 'Transfer-Encoding: chunked' headers are added when the response is used with #MHD_HTTP_STATUS_NOT_MODIFIED code or to respond to HEAD request.
|
||||
+ The flag also allow to set arbitrary 'Content-Length' by #MHD_response_add_header() function.
|
||||
+ This flag value can be used only with responses created without body (zero-size body).
|
||||
+ Responses with this flag enabled cannot be used in situations where reply body must be sent to the client.
|
||||
+ This flag is primarily intended to be used when automatic "Content-Length" header is undesirable in response to HEAD requests.
|
||||
+ This flag is primarily intended to be used when automatic 'Content-Length' header is undesirable in response to HEAD requests.
|
||||
|
||||
Name: CHUNKED_ENC
|
||||
Value: 41
|
||||
@@ -46,7 +46,7 @@ Comment: Force use of chunked encoding even if the response content size is know
|
||||
Name: CONN_CLOSE
|
||||
Value: 60
|
||||
Type: enum MHD_Bool
|
||||
Comment: Force close connection after sending the response, prevents keep-alive connections and adds "Connection: close" header.
|
||||
Comment: Force close connection after sending the response, prevents keep-alive connections and adds 'Connection: close' header.
|
||||
|
||||
# Compatibility settings
|
||||
|
||||
@@ -64,11 +64,11 @@ Value: 81
|
||||
Type: enum MHD_Bool
|
||||
Comment: Only respond in HTTP/1.0-mode.
|
||||
+ Contrary to the #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT flag, the response's HTTP version will always be set to 1.0 and keep-alive connections will be used if explicitly requested by the client.
|
||||
+ The "Connection:" header will be added for both "close" and "keep-alive" connections.
|
||||
+ The 'Connection:' header will be added for both 'close' and 'keep-alive' connections.
|
||||
+ Chunked encoding will not be used for the response.
|
||||
+ Due to backward compatibility, responses still can be used with HTTP/1.1 clients.
|
||||
+ This option can be used to emulate HTTP/1.0 server (for response part only as chunked encoding in requests (if any) is processed by MHD).
|
||||
+ With this option HTTP/1.0 server is emulated (with support for "keep-alive" connections).
|
||||
+ With this option HTTP/1.0 server is emulated (with support for 'keep-alive' connections).
|
||||
|
||||
# Violate HTTP and/or RFCs
|
||||
|
||||
@@ -76,7 +76,7 @@ Name: INSANITY_HEADER_CONTENT_LENGTH
|
||||
Value: 100
|
||||
Type: enum MHD_Bool
|
||||
Comment: Disable sanity check preventing clients from manually setting the HTTP content length option.
|
||||
+ Allow to set several "Content-Length" headers. These headers will be used even with replies without body.
|
||||
+ Allow to set several 'Content-Length' headers. These headers will be used even with replies without body.
|
||||
|
||||
# Callbacks
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
/* This is generated code, it is still under LGPLv3+.
|
||||
Do not edit directly! */
|
||||
/* *INDENT-OFF* */
|
||||
/**
|
||||
/* @file daemon_options.h
|
||||
/* @author daemon-options-generator.c
|
||||
*/
|
||||
|
||||
#include "microhttpd2.h"
|
||||
#include "internal.h"
|
||||
|
||||
struct DaemonOptions {
|
||||
/**
|
||||
* Value for #MHD_D_O_WORK_MODE.
|
||||
* the object created by one of the next functions/macros: #MHD_WM_OPTION_EXTERNAL_PERIODIC(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(), #MHD_WM_OPTION_WORKER_THREADS(), #MHD_WM_OPTION_THREAD_PER_CONNECTION()
|
||||
*/
|
||||
struct MHD_WorkModeWithParam work_mode;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_POLL_SYSCALL.
|
||||
* FIXME
|
||||
*/
|
||||
enum MHD_SockPollSyscall poll_syscall;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LOG_CALLBACK.
|
||||
* the callback to use for logging,
|
||||
* NULL to disable logging
|
||||
*/
|
||||
struct MHD_DaemonOptionValueLog log_callback;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_BIND_PORT.
|
||||
* the address family to use,
|
||||
* the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used)
|
||||
*/
|
||||
struct MHD_DaemonOptionValueBind bind_port;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_BIND_SA.
|
||||
* the size of the socket address pointed by @a sa.
|
||||
*/
|
||||
struct MHD_DaemonOptionValueSA bind_sa;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LISTEN_SOCKET.
|
||||
* the listen socket to use, ignored if set to #MHD_INVALID_SOCKET
|
||||
*/
|
||||
MHD_socket listen_socket;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LISTEN_ADDR_REUSE.
|
||||
* FIXME
|
||||
*/
|
||||
enum MHD_DaemonOptionBindType listen_addr_reuse;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TCP_FASTOPEN.
|
||||
* the type use of of TCP FastOpen
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTFO tcp_fastopen;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LISTEN_BACKLOG.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int listen_backlog;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_SIGPIPE_SUPPRESSED.
|
||||
*/
|
||||
enum MHD_Bool sigpipe_suppressed;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS.
|
||||
* the TLS backend to use,
|
||||
* #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections
|
||||
*/
|
||||
enum MHD_TlsBackend tls;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS_KEY_CERT.
|
||||
* the private key loaded into memory (not a filename)
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTlsCert tls_key_cert;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS_CLIENT_CA.
|
||||
* the CA certificate in memory (not a filename)
|
||||
*/
|
||||
const char *tls_client_ca;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TLS_PSK_CALLBACK.
|
||||
* the function to call to obtain pre-shared key
|
||||
*/
|
||||
struct MHD_DaemonOptionValueTlsPskCB tls_psk_callback;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_NO_ALPN.
|
||||
*/
|
||||
enum MHD_Bool no_alpn;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DEFAULT_TIMEOUT.
|
||||
* the in seconds, zero for no timeout
|
||||
*/
|
||||
unsigned int default_timeout;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_GLOBAL_CONNECTION_LIMIT.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int global_connection_limit;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_PER_IP_LIMIT.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int per_ip_limit;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_ACCEPT_POLICY.
|
||||
* the accept policy callback
|
||||
*/
|
||||
struct MHD_DaemonOptionValueAcceptPol accept_policy;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_PROTOCOL_STRICT_LEVEL.
|
||||
* the level of strictness
|
||||
*/
|
||||
struct MHD_DaemonOptionValueStrctLvl protocol_strict_level;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_EARLY_URI_LOGGER.
|
||||
* the early URI callback
|
||||
*/
|
||||
struct MHD_DaemonOptionValueUriCB early_uri_logger;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE.
|
||||
*/
|
||||
enum MHD_Bool disable_uri_query_plus_as_space;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_SUPPRESS_DATE_HEADER.
|
||||
*/
|
||||
enum MHD_Bool suppress_date_header;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_ENABLE_SHOUTCAST.
|
||||
*/
|
||||
enum MHD_Bool enable_shoutcast;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_CONN_MEMORY_LIMIT.
|
||||
*/
|
||||
size_t conn_memory_limit;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_LARGE_POOL_SIZE.
|
||||
*/
|
||||
size_t large_pool_size;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_STACK_SIZE.
|
||||
*/
|
||||
size_t stack_size;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_FD_NUMBER_LIMIT.
|
||||
* FIXME
|
||||
*/
|
||||
MHD_socket fd_number_limit;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_TURBO.
|
||||
*/
|
||||
enum MHD_Bool turbo;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISABLE_THREAD_SAFETY.
|
||||
*/
|
||||
enum MHD_Bool disable_thread_safety;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISALLOW_UPGRADE.
|
||||
*/
|
||||
enum MHD_Bool disallow_upgrade;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISALLOW_SUSPEND_RESUME.
|
||||
*/
|
||||
enum MHD_Bool disallow_suspend_resume;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAEMON_READY_CALLBACK.
|
||||
* the pre-start callback
|
||||
*/
|
||||
struct MHD_DaemonOptionValueReadyCB daemon_ready_callback;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_NOTIFY_CONNECTION.
|
||||
* the callback for notifications
|
||||
*/
|
||||
struct MHD_DaemonOptionValueNotifConnCB notify_connection;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_NOTIFY_STREAM.
|
||||
* the callback for notifications
|
||||
*/
|
||||
struct MHD_DaemonOptionValueNotifStreamCB notify_stream;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_RANDOM_ENTROPY.
|
||||
* the size of the buffer
|
||||
*/
|
||||
struct MHD_DaemonOptionValueRand random_entropy;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_MAP_SIZE.
|
||||
* the size of the map array
|
||||
*/
|
||||
size_t dauth_map_size;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_NONCE_BIND_TYPE.
|
||||
* FIXME
|
||||
*/
|
||||
enum MHD_DaemonOptionValueDAuthBindNonce dauth_nonce_bind_type;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_DEF_NONCE_TIMEOUT.
|
||||
* FIXME
|
||||
*/
|
||||
unsigned int dauth_def_nonce_timeout;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAUTH_DEF_MAX_NC.
|
||||
* FIXME
|
||||
*/
|
||||
uint_fast32_t dauth_def_max_nc;
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
/* This is generated code, it is still under LGPLv3+.
|
||||
Do not edit directly! */
|
||||
/* *INDENT-OFF* */
|
||||
/**
|
||||
/* @file daemon_set_options.c
|
||||
/* @author daemon-options-generator.c
|
||||
*/
|
||||
|
||||
#include "microhttpd2.h"
|
||||
#include "internal.h"
|
||||
|
||||
enum MHD_StatusCode
|
||||
MHD_daemon_set_options (
|
||||
struct MHD_Daemon *daemon,
|
||||
const struct MHD_DaemonOptionAndValue *options,
|
||||
size_t options_max_num)
|
||||
{
|
||||
for (size_t i=0;i<options_max_num;i++)
|
||||
{
|
||||
switch (options[i].opt) {
|
||||
case MHD_D_OPTION_WORK_MODE:
|
||||
daemon->settings.work_mode = option->val.work_mode;
|
||||
continue;
|
||||
case MHD_D_OPTION_POLL_SYSCALL:
|
||||
daemon->settings.poll_syscall = option->val.poll_syscall;
|
||||
continue;
|
||||
case MHD_D_OPTION_LOG_CALLBACK:
|
||||
daemon->settings.log_callback.v_log_cb = option->val.log_callback.v_log_cb;
|
||||
daemon->settings.log_callback.v_lob_cb_cls = option->val.log_callback.v_lob_cb_cls;
|
||||
continue;
|
||||
case MHD_D_OPTION_BIND_PORT:
|
||||
daemon->settings.bind_port.v_af = option->val.bind_port.v_af;
|
||||
daemon->settings.bind_port.v_port = option->val.bind_port.v_port;
|
||||
continue;
|
||||
case MHD_D_OPTION_BIND_SA:
|
||||
daemon->settings.bind_sa.v_sa_len = option->val.bind_sa.v_sa_len;
|
||||
daemon->settings.bind_sa.v_sa = option->val.bind_sa.v_sa;
|
||||
continue;
|
||||
case MHD_D_OPTION_LISTEN_SOCKET:
|
||||
daemon->settings.listen_socket = option->val.listen_socket;
|
||||
continue;
|
||||
case MHD_D_OPTION_LISTEN_ADDR_REUSE:
|
||||
daemon->settings.listen_addr_reuse = option->val.listen_addr_reuse;
|
||||
continue;
|
||||
case MHD_D_OPTION_TCP_FASTOPEN:
|
||||
daemon->settings.tcp_fastopen.v_option = option->val.tcp_fastopen.v_option;
|
||||
daemon->settings.tcp_fastopen.v_queue_length = option->val.tcp_fastopen.v_queue_length;
|
||||
continue;
|
||||
case MHD_D_OPTION_LISTEN_BACKLOG:
|
||||
daemon->settings.listen_backlog = option->val.listen_backlog;
|
||||
continue;
|
||||
case MHD_D_OPTION_SIGPIPE_SUPPRESSED:
|
||||
daemon->settings.sigpipe_suppressed = option->val.sigpipe_suppressed;
|
||||
continue;
|
||||
case MHD_D_OPTION_TLS:
|
||||
daemon->settings.tls = option->val.tls;
|
||||
continue;
|
||||
case MHD_D_OPTION_TLS_KEY_CERT:
|
||||
daemon->settings.tls_key_cert.v_mem_key = option->val.tls_key_cert.v_mem_key;
|
||||
daemon->settings.tls_key_cert.v_mem_cert = option->val.tls_key_cert.v_mem_cert;
|
||||
daemon->settings.tls_key_cert.v_mem_pass = option->val.tls_key_cert.v_mem_pass;
|
||||
continue;
|
||||
case MHD_D_OPTION_TLS_CLIENT_CA:
|
||||
daemon->settings.tls_client_ca = option->val.tls_client_ca;
|
||||
continue;
|
||||
case MHD_D_OPTION_TLS_PSK_CALLBACK:
|
||||
daemon->settings.tls_psk_callback.v_psk_cb = option->val.tls_psk_callback.v_psk_cb;
|
||||
daemon->settings.tls_psk_callback.v_psk_cb_cls = option->val.tls_psk_callback.v_psk_cb_cls;
|
||||
continue;
|
||||
case MHD_D_OPTION_NO_ALPN:
|
||||
daemon->settings.no_alpn = option->val.no_alpn;
|
||||
continue;
|
||||
case MHD_D_OPTION_DEFAULT_TIMEOUT:
|
||||
daemon->settings.default_timeout = option->val.default_timeout;
|
||||
continue;
|
||||
case MHD_D_OPTION_GLOBAL_CONNECTION_LIMIT:
|
||||
daemon->settings.global_connection_limit = option->val.global_connection_limit;
|
||||
continue;
|
||||
case MHD_D_OPTION_PER_IP_LIMIT:
|
||||
daemon->settings.per_ip_limit = option->val.per_ip_limit;
|
||||
continue;
|
||||
case MHD_D_OPTION_ACCEPT_POLICY:
|
||||
daemon->settings.accept_policy.v_apc = option->val.accept_policy.v_apc;
|
||||
daemon->settings.accept_policy.v_apc_cls = option->val.accept_policy.v_apc_cls;
|
||||
continue;
|
||||
case MHD_D_OPTION_PROTOCOL_STRICT_LEVEL:
|
||||
daemon->settings.protocol_strict_level.v_sl = option->val.protocol_strict_level.v_sl;
|
||||
daemon->settings.protocol_strict_level.v_how = option->val.protocol_strict_level.v_how;
|
||||
continue;
|
||||
case MHD_D_OPTION_EARLY_URI_LOGGER:
|
||||
daemon->settings.early_uri_logger.v_cb = option->val.early_uri_logger.v_cb;
|
||||
daemon->settings.early_uri_logger.v_cls = option->val.early_uri_logger.v_cls;
|
||||
continue;
|
||||
case MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE:
|
||||
daemon->settings.disable_uri_query_plus_as_space = option->val.disable_uri_query_plus_as_space;
|
||||
continue;
|
||||
case MHD_D_OPTION_SUPPRESS_DATE_HEADER:
|
||||
daemon->settings.suppress_date_header = option->val.suppress_date_header;
|
||||
continue;
|
||||
case MHD_D_OPTION_ENABLE_SHOUTCAST:
|
||||
daemon->settings.enable_shoutcast = option->val.enable_shoutcast;
|
||||
continue;
|
||||
case MHD_D_OPTION_CONN_MEMORY_LIMIT:
|
||||
daemon->settings.conn_memory_limit = option->val.conn_memory_limit;
|
||||
continue;
|
||||
case MHD_D_OPTION_LARGE_POOL_SIZE:
|
||||
daemon->settings.large_pool_size = option->val.large_pool_size;
|
||||
continue;
|
||||
case MHD_D_OPTION_STACK_SIZE:
|
||||
daemon->settings.stack_size = option->val.stack_size;
|
||||
continue;
|
||||
case MHD_D_OPTION_FD_NUMBER_LIMIT:
|
||||
daemon->settings.fd_number_limit = option->val.fd_number_limit;
|
||||
continue;
|
||||
case MHD_D_OPTION_TURBO:
|
||||
daemon->settings.turbo = option->val.turbo;
|
||||
continue;
|
||||
case MHD_D_OPTION_DISABLE_THREAD_SAFETY:
|
||||
daemon->settings.disable_thread_safety = option->val.disable_thread_safety;
|
||||
continue;
|
||||
case MHD_D_OPTION_DISALLOW_UPGRADE:
|
||||
daemon->settings.disallow_upgrade = option->val.disallow_upgrade;
|
||||
continue;
|
||||
case MHD_D_OPTION_DISALLOW_SUSPEND_RESUME:
|
||||
daemon->settings.disallow_suspend_resume = option->val.disallow_suspend_resume;
|
||||
continue;
|
||||
case MHD_D_OPTION_DAEMON_READY_CALLBACK:
|
||||
daemon->settings.daemon_ready_callback.v_cb = option->val.daemon_ready_callback.v_cb;
|
||||
daemon->settings.daemon_ready_callback.v_cb_cls = option->val.daemon_ready_callback.v_cb_cls;
|
||||
continue;
|
||||
case MHD_D_OPTION_NOTIFY_CONNECTION:
|
||||
daemon->settings.notify_connection.v_ncc = option->val.notify_connection.v_ncc;
|
||||
daemon->settings.notify_connection.v_cls = option->val.notify_connection.v_cls;
|
||||
continue;
|
||||
case MHD_D_OPTION_NOTIFY_STREAM:
|
||||
daemon->settings.notify_stream.v_nsc = option->val.notify_stream.v_nsc;
|
||||
daemon->settings.notify_stream.v_cls = option->val.notify_stream.v_cls;
|
||||
continue;
|
||||
case MHD_D_OPTION_RANDOM_ENTROPY:
|
||||
daemon->settings.random_entropy.v_buf_size = option->val.random_entropy.v_buf_size;
|
||||
daemon->settings.random_entropy.v_buf = option->val.random_entropy.v_buf;
|
||||
continue;
|
||||
case MHD_D_OPTION_DAUTH_MAP_SIZE:
|
||||
daemon->settings.dauth_map_size = option->val.dauth_map_size;
|
||||
continue;
|
||||
case MHD_D_OPTION_DAUTH_NONCE_BIND_TYPE:
|
||||
daemon->settings.dauth_nonce_bind_type = option->val.dauth_nonce_bind_type;
|
||||
continue;
|
||||
case MHD_D_OPTION_DAUTH_DEF_NONCE_TIMEOUT:
|
||||
daemon->settings.dauth_def_nonce_timeout = option->val.dauth_def_nonce_timeout;
|
||||
continue;
|
||||
case MHD_D_OPTION_DAUTH_DEF_MAX_NC:
|
||||
daemon->settings.dauth_def_max_nc = option->val.dauth_def_max_nc;
|
||||
continue;
|
||||
}
|
||||
return MHD_SC_OPTION_UNSUPPORTED;
|
||||
}
|
||||
return MHD_SC_OK;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* This is generated code, it is still under LGPLv3+.
|
||||
Do not edit directly! */
|
||||
/* *INDENT-OFF* */
|
||||
/**
|
||||
/* @file response_options.h
|
||||
/* @author response-options-generator.c
|
||||
*/
|
||||
|
||||
#include "microhttpd2.h"
|
||||
#include "internal.h"
|
||||
|
||||
struct ResponseOptions {
|
||||
/**
|
||||
* Value for #MHD_R_O_REUSABLE.
|
||||
*/
|
||||
enum MHD_Bool reusable;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_HEAD_ONLY_RESPONSE.
|
||||
*/
|
||||
enum MHD_Bool head_only_response;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_CHUNKED_ENC.
|
||||
*/
|
||||
enum MHD_Bool chunked_enc;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_CONN_CLOSE.
|
||||
*/
|
||||
enum MHD_Bool conn_close;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT.
|
||||
*/
|
||||
enum MHD_Bool http_1_0_compatible_strict;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_HTTP_1_0_SERVER.
|
||||
*/
|
||||
enum MHD_Bool http_1_0_server;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH.
|
||||
*/
|
||||
enum MHD_Bool insanity_header_content_length;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_R_O_TERMINATION_CALLBACK.
|
||||
* the function to call,
|
||||
* NULL to not use the callback
|
||||
*/
|
||||
struct MHD_ResponeOptionValueTermCB termination_callback;
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/* This is generated code, it is still under LGPLv3+.
|
||||
Do not edit directly! */
|
||||
/* *INDENT-OFF* */
|
||||
/**
|
||||
/* @file response_set_options.c
|
||||
/* @author response-options-generator.c
|
||||
*/
|
||||
|
||||
#include "microhttpd2.h"
|
||||
#include "internal.h"
|
||||
|
||||
enum MHD_StatusCode
|
||||
MHD_response_set_options (
|
||||
struct MHD_Response *response,
|
||||
const struct MHD_ResponseOptionAndValue *options,
|
||||
size_t options_max_num)
|
||||
{
|
||||
for (size_t i=0;i<options_max_num;i++)
|
||||
{
|
||||
switch (options[i].opt) {
|
||||
case MHD_R_OPTION_REUSABLE:
|
||||
response->settings.reusable = option->val.reusable;
|
||||
continue;
|
||||
case MHD_R_OPTION_HEAD_ONLY_RESPONSE:
|
||||
response->settings.head_only_response = option->val.head_only_response;
|
||||
continue;
|
||||
case MHD_R_OPTION_CHUNKED_ENC:
|
||||
response->settings.chunked_enc = option->val.chunked_enc;
|
||||
continue;
|
||||
case MHD_R_OPTION_CONN_CLOSE:
|
||||
response->settings.conn_close = option->val.conn_close;
|
||||
continue;
|
||||
case MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT:
|
||||
response->settings.http_1_0_compatible_strict = option->val.http_1_0_compatible_strict;
|
||||
continue;
|
||||
case MHD_R_OPTION_HTTP_1_0_SERVER:
|
||||
response->settings.http_1_0_server = option->val.http_1_0_server;
|
||||
continue;
|
||||
case MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH:
|
||||
response->settings.insanity_header_content_length = option->val.insanity_header_content_length;
|
||||
continue;
|
||||
case MHD_R_OPTION_TERMINATION_CALLBACK:
|
||||
response->settings.termination_callback.v_term_cb = option->val.termination_callback.v_term_cb;
|
||||
response->settings.termination_callback.v_term_cb_cls = option->val.termination_callback.v_term_cb_cls;
|
||||
continue;
|
||||
}
|
||||
return MHD_SC_OPTION_UNSUPPORTED;
|
||||
}
|
||||
return MHD_SC_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user