libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

microhttpd2_preamble.h.in (140244B)


      1 /* SPDX-License-Identifier: LGPL-2.1-or-later OR (GPL-2.0-or-later WITH eCos-exception-2.0) */
      2 /*
      3   This file is part of GNU libmicrohttpd.
      4   Copyright (C) 2006-2026 Christian Grothoff, Karlson2k (Evgeny Grin)
      5   (and other contributing authors)
      6 
      7   GNU libmicrohttpd is free software; you can redistribute it and/or
      8   modify it under the terms of the GNU Lesser General Public
      9   License as published by the Free Software Foundation; either
     10   version 2.1 of the License, or (at your option) any later version.
     11 
     12   GNU libmicrohttpd is distributed in the hope that it will be useful,
     13   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15   Lesser General Public License for more details.
     16 
     17   Alternatively, you can redistribute GNU libmicrohttpd and/or
     18   modify it under the terms of the GNU General Public License as
     19   published by the Free Software Foundation; either version 2 of
     20   the License, or (at your option) any later version, together
     21   with the eCos exception, as follows:
     22 
     23     As a special exception, if other files instantiate templates or
     24     use macros or inline functions from this file, or you compile this
     25     file and link it with other works to produce a work based on this
     26     file, this file does not by itself cause the resulting work to be
     27     covered by the GNU General Public License. However the source code
     28     for this file must still be made available in accordance with
     29     section (3) of the GNU General Public License v2.
     30 
     31     This exception does not invalidate any other reasons why a work
     32     based on this file might be covered by the GNU General Public
     33     License.
     34 
     35   You should have received copies of the GNU Lesser General Public
     36   License and the GNU General Public License along with this library;
     37   if not, see <https://www.gnu.org/licenses/>.
     38 */
     39 
     40 /*
     41   Main goals for the libmicrohttpd 2.0 API:
     42 
     43   - simplify application callbacks by splitting header/upload/post
     44     functionality currently provided by calling the same
     45     MHD_AccessHandlerCallback 3+ times into separate callbacks.
     46   - keep the API very simple for simple requests, but allow
     47     more complex logic to be incrementally introduced
     48     (via new struct MHD_Action construction)
     49   - avoid repeated scans for URL matches via the new
     50     struct MHD_Action construction
     51   - better types, in particular avoid varargs for options
     52   - make it harder to pass inconsistent options
     53   - combine options and flags into more uniform API (at least
     54     exterally!)
     55   - simplify API use by using sane defaults (benefiting from
     56     breaking backwards compatibility) and making all options
     57     really optional, and where applicable avoid having options
     58     where the default works if nothing is specified
     59   - simplify API by moving rarely used http_version into
     60     MHD_request_get_info_fixed()
     61   - avoid 'int' for MHD_YES/MHD_NO by introducing `enum MHD_Bool`
     62   - improve terminology by eliminating confusion between
     63     'request' and 'connection'; add 'session' for HTTP2/3;
     64     use clear separation between connection and request. Do not mix the kind
     65     data in the callbacks.  Currently we are mixing things in
     66     MHD_AccessHandlerCallback and MHD_RequestCompletedCallback. Instead of
     67     pointers to struct MHD_Connection we should use pointers to (new) struct
     68     MHD_Request.
     69   - prepare API for having multiple TLS backends
     70   - use more consistent prefixes for related functions
     71     by using MHD_subject_verb_object naming convention, also
     72     at the same time avoid symbol conflict with legacy names
     73     (so we can have one binary implementing old and new
     74     library API at the same time via compatibility layer).
     75   - make it impossible to queue a response at the wrong time
     76   - make it impossible to suspend a connection/request at the
     77     wrong time (improves thread-safety)
     78   - make it clear which response status codes are "properly"
     79     supported (include the descriptive string) by using an enum;
     80   - simplify API for common-case of one-shot responses by
     81     eliminating need for destroy response in most cases;
     82   - avoid fixed types, like uint32_t. They may not exist on some
     83     platforms. Instead use uint_fast32_t.
     84     It is also better for future-proof.
     85   - check portability for embedded platforms. Some of them support
     86     64 bits, but 'int' could be just 16 bits resulting of silently
     87     dropping enum values higher than 65535.
     88     => in general, more functions, fewer enums for setup
     89   - Avoid returning pointers to internal members. It is not thread-safe and
     90     even in single thread the value could change over the time. Prefer pointers to
     91     app-allocated memory with the size, like MHD_daemon_get_static_info(enum
     92     MHD_enum_name info_type, void *buf, size_t buf_size).
     93     => Except in cases where zero-copy matters.
     94   - Use separate app calls/functions for data the will not change for the
     95     lifetime of the object and dynamic data. The only difference should be the
     96     name. Like MHD_daemon_get_static_info(enum MHD_enum_name info_type, void *buf,
     97     size_t buf_size) MHD_daemon_get_dynamic_info(enum MHD_enum_name info_type,
     98     void *buf, size_t buf_size) Examples of static data: listen socket, number of
     99     workers, daemon flags.  Examples of dynamic data: number of connections,
    100     quiesce status.  It should give a clear idea whether the data could be changed
    101     over the time (could be not obvious for some data) and thus may change the
    102     approach how to use the data in app.  The same for: library, daemon,
    103     connection, request. Not sure that dynamic data makes sense for the library.
    104   - Define response code in response object. There are a very little
    105     chance that response body designed for 404 or 403 codes will be used with
    106     200 code. However, the responses body for 307 and 308 could be the same. So:
    107     Add default response code in response object.
    108   - Make responses unmodifiable after first use. It is not thread-safe.
    109     MHD-generated headers (Date, Connection/Keep-Alive) are again
    110     part of the *request* and do not count as part of the "response" here.
    111   - Remove "footers" from responses. With unmodifiable responses everything should
    112     be "headers". Add footers to *requests* instead.
    113   - Add API for adding request-specific response headers and footers. To
    114     simplify the things it should just copy the strings (to avoid dealing with
    115     complicated deinit of possible dynamic strings).  After this change it should
    116     be possible to simplify DAuth handling as response could be reused (currently
    117     403 responses are modified for each reply).
    118   - Control response behaviour mainly by response flags, not by additional
    119     headers (like MHD_RF_FORCE_CLOSE instead of "Connection: close").
    120     It is easier&faster for both: app and MHD.
    121   - Move response codes from MHD_HTTP_xxx namespace to MHD_HTTP_CODE_xxx
    122     namespace. It already may clash with other HTTP values.
    123   - Postprocessor is unusable night-mare when doing "stream processing"
    124     for tiny values where the application basically has to copy together
    125     the stream back into a single compact heap value, just making the
    126     parsing highly more complicated (see examples in Challenger)
    127   - non-stream processing variant for request bodies, give apps a
    128     way to request the full body in one buffer; give apps a way
    129     to request a 'large new allocation' for such buffers; give apps
    130     a way to specify a global quota for large allocations to ensure
    131     memory usage has a hard bound
    132 
    133   - Internals: carefully check where locking is really required. Probably
    134     separate locks. Check out-of-thread value reading. Currently code assumes
    135     atomic reading of values used in other threads, which mostly true on x86,
    136     but not OK on other arches. Probably use read/write locking to minimize
    137     the threads interference.
    138   - Internals: figure out how to do portable variant of cork/uncork
    139   - Internals: remove request data from memory pool when response is queued
    140     (IF no callbacks and thus data cannot be used anymore, or IF
    141      application permits explicitly per daemon) to get more space
    142     for building response;
    143   - Internals: Fix TCP FIN graceful closure issue for upgraded
    144     connections (API implications?)
    145 
    146 */
    147 
    148 #ifndef MICROHTTPD2_H
    149 #define MICROHTTPD2_H
    150 
    151 #ifndef __cplusplus
    152 #  define MHD_C_DECLRATIONS_START_HERE_   /* Empty */
    153 #  define MHD_C_DECLRATIONS_FINISH_HERE_  /* Empty */
    154 #else  /* __cplusplus */
    155 /* *INDENT-OFF* */
    156 #  define MHD_C_DECLRATIONS_START_HERE_   extern "C" {
    157 #  define MHD_C_DECLRATIONS_FINISH_HERE_  }
    158 /* *INDENT-ON* */
    159 #endif /* __cplusplus */
    160 
    161 MHD_C_DECLRATIONS_START_HERE_
    162 
    163 /**
    164  * Current version of the library in packed BCD form.
    165  * (For example, version 1.9.30-1 would be 0x01093001)
    166  */
    167 #define MHD_VERSION 0x01990001
    168 
    169 #include "microhttpd2_portability.h"
    170 
    171 /* If generic headers do not work on your platform, include headers that
    172    define 'va_list', 'size_t', 'uint_least16_t', 'uint_fast32_t',
    173    'uint_fast64_t', and 'struct sockaddr', and then
    174    add "#define MHD_HAVE_SYS_HEADERS_INCLUDED" before including "microhttpd2.h".
    175    When 'MHD_HAVE_SYS_HEADERS_INCLUDED' is defined, the following "standard"
    176    includes will not be used (which might be a good idea, especially on
    177    platforms where they do not exist).
    178    */
    179 #ifndef MHD_HAVE_SYS_HEADERS_INCLUDED
    180 #  include <stdarg.h>
    181 #  ifndef MHD_SYS_BASE_TYPES_H
    182 /* Headers for uint_fastXX_t, size_t */
    183 #    include <stdint.h>
    184 #    include <stddef.h>
    185 #    include <sys/types.h> /* This header is actually optional */
    186 #  endif
    187 #  ifndef MHD_SYS_SOCKET_TYPES_H
    188 /* Headers for 'struct sockaddr' */
    189 #    if ! defined(_WIN32) || defined(__CYGWIN__)
    190 #      include <sys/socket.h>
    191 #    else
    192 /* Prevent conflict of <winsock.h> and <winsock2.h> */
    193 #      if ! defined(_WINSOCK2API_) && ! defined(_WINSOCKAPI_)
    194 #        ifndef WIN32_LEAN_AND_MEAN
    195 /* Do not use unneeded parts of W32 headers. */
    196 #          define WIN32_LEAN_AND_MEAN 1
    197 #        endif /* !WIN32_LEAN_AND_MEAN */
    198 #        include <winsock2.h>
    199 #      endif
    200 #    endif
    201 #  endif
    202 #endif
    203 
    204 #ifndef MHD_BOOL_DEFINED
    205 
    206 /**
    207  * Representation of 'bool' in the public API as stdbool.h may not
    208  * always be available and presence of 'bool' keyword may depend on
    209  * used C version.
    210  * It is always safe to cast 'MHD_Bool' variable to 'bool' and vice versa.
    211  * Note: it may be UNSAFE to cast pointers 'MHD_Bool*' to 'bool*' and
    212  *       vice versa.
    213  */
    214 enum MHD_Bool
    215 {
    216 
    217   /**
    218    * MHD-internal return code for "NO".
    219    */
    220   MHD_NO = 0
    221   ,
    222   /**
    223    * MHD-internal return code for "YES".  All non-zero values
    224    * will be interpreted as "YES", but MHD will only ever
    225    * return #MHD_YES or #MHD_NO.
    226    */
    227   MHD_YES = 1
    228 };
    229 
    230 
    231 #define MHD_BOOL_DEFINED 1
    232 #endif /* ! MHD_BOOL_DEFINED */
    233 
    234 #ifndef MHD_STRINGS_DEFINED
    235 
    236 
    237 /**
    238  * String with length data.
    239  * This type should always have valid @a cstr pointer.
    240  */
    241 struct MHD_String
    242 {
    243   /**
    244    * Number of characters in @e str, not counting 0-termination.
    245    */
    246   size_t len;
    247 
    248   /**
    249    * 0-terminated C-string.
    250    * Must not be NULL.
    251    */
    252   const char *cstr;
    253 };
    254 
    255 /**
    256  * String with length data.
    257  * This type of data may have NULL as the @a cstr pointer.
    258  */
    259 struct MHD_StringNullable
    260 {
    261   /**
    262    * Number of characters in @e cstr, not counting 0-termination.
    263    * If @a cstr is NULL, it must be zero.
    264    */
    265   size_t len;
    266 
    267   /**
    268    * 0-terminated C-string.
    269    * In some cases it could be NULL.
    270    */
    271   const char *cstr;
    272 };
    273 
    274 #define MHD_STRINGS_DEFINED 1
    275 #endif /* ! MHD_STRINGS_DEFINED */
    276 
    277 
    278 #ifndef MHD_INVALID_SOCKET
    279 #  if ! defined(_WIN32) || defined(_SYS_TYPES_FD_SET)
    280 #    define MHD_SOCKETS_KIND_POSIX 1
    281 /**
    282  * MHD_Socket is a type for socket FDs
    283  */
    284 typedef int MHD_Socket;
    285 #    define MHD_INVALID_SOCKET (-1)
    286 #  else /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
    287 #    define MHD_SOCKETS_KIND_WINSOCK 1
    288 /**
    289  * MHD_Socket is a type for socket FDs
    290  */
    291 typedef SOCKET MHD_Socket;
    292 #    define MHD_INVALID_SOCKET (INVALID_SOCKET)
    293 #  endif /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
    294 #endif /* MHD_INVALID_SOCKET */
    295 
    296 
    297 /**
    298  * Constant used to indicate unknown size (use when creating a response).
    299  * Any possible larger sizes are interpreted as the same value.
    300  */
    301 #ifdef UINT64_MAX
    302 #  define MHD_SIZE_UNKNOWN UINT64_MAX
    303 #else
    304 #  define MHD_SIZE_UNKNOWN \
    305         MHD_STATIC_CAST_ (uint_fast64_t,0xffffffffffffffffU)
    306 #endif
    307 
    308 
    309 /**
    310  * Constant used to indicate unlimited wait time.
    311  * Any possible larger values are interpreted as this value.
    312  */
    313 #ifdef UINT64_MAX
    314 #  define MHD_WAIT_INDEFINITELY UINT64_MAX
    315 #else
    316 #  define MHD_WAIT_INDEFINITELY \
    317         MHD_STATIC_CAST_ (uint_fast64_t,0xffffffffffffffffU)
    318 #endif
    319 
    320 
    321 /* ********** (a) Core HTTP Processing ************ */
    322 
    323 
    324 /**
    325  * @brief Handle for a daemon that listens for requests.
    326  *
    327  * Manages the listen socket, event loop, optional threads and server
    328  * settings.
    329  *
    330  * @defgroup daemon HTTP server handling client connections
    331  */
    332 struct MHD_Daemon;
    333 
    334 
    335 /**
    336  * @brief Handle/identifier of a network connection abstraction.
    337  *
    338  * A single network (i.e. TCP) connection can be used for
    339  * a single (in HTTP/1.1) data stream.
    340  *
    341  * @defgroup connection client connection with streams
    342  */
    343 struct MHD_Connection;
    344 
    345 
    346 /**
    347  * @brief Handle/identifier of a data stream over network
    348  * connection.
    349  *
    350  * A data stream may be used for multiple requests, which
    351  * in HTTP/1.1 must be processed sequentially.
    352  *
    353  * @defgroup stream stream of HTTP requests
    354  */
    355 struct MHD_Stream;
    356 
    357 /**
    358  * @brief Handle representing an HTTP request.
    359  *
    360  * With HTTP/1.1, multiple requests can be run over the same
    361  * stream.  However, MHD will only show one request per data
    362  * stream to the client at any given time.
    363  *
    364  * Replaces `struct MHD_Connection` in the API prior to version 2.0.0,
    365  * renamed to better reflect what this object truly represents to
    366  * the application using MHD.
    367  *
    368  * @defgroup request HTTP requests
    369  */
    370 struct MHD_Request;
    371 
    372 
    373 /**
    374  * @brief Actions are returned by the application when processed client header
    375  * to drive the request handling of MHD.
    376  *
    377  * @defgroup action Request actions
    378  */
    379 struct MHD_Action;
    380 
    381 
    382 /**
    383  * @brief Actions are returned by the application when processing client upload
    384  * to drive the request handling of MHD.
    385  *
    386  * @defgroup action Request actions
    387  */
    388 struct MHD_UploadAction;
    389 
    390 /**
    391  * @defgroup general Primary MHD functions and data
    392  */
    393 
    394 /**
    395  * @defgroup specialized Introspection and other special control
    396  */
    397 
    398 /**
    399  * @defgroup authentication Digest and other HTTP authentications
    400  */
    401 
    402 
    403 /**
    404  * Return values for reporting errors, also used for logging.
    405  *
    406  * A value of 0 indicates success (as a return value).
    407  * Values between 0 and 10000 must be handled explicitly by the app.
    408  * Values from 10000-19999 are informational.
    409  * Values from 20000-29999 indicate successful operations.
    410  * Values from 30000-39999 indicate unsuccessful (normal) operations.
    411  * Values from 40000-49999 indicate client errors.
    412  * Values from 50000-59999 indicate MHD server errors.
    413  * Values from 60000-65535 indicate application errors.
    414  *
    415  * @ingroup general
    416  */
    417 enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode
    418 {
    419 
    420   /* 00000-level status codes indicate return values
    421      the application must act on. */
    422 
    423   /**
    424    * Successful operation (not used for logging).
    425    * The code is guaranteed to be always zero.
    426    */
    427   MHD_SC_OK = 0
    428   ,
    429 
    430   /* 10000-level status codes indicate intermediate
    431      results of some kind. */
    432 
    433   /**
    434    * Informational event, MHD started.
    435    */
    436   MHD_SC_DAEMON_STARTED = 10000
    437   ,
    438   /**
    439    * Informational event, we accepted a connection.
    440    */
    441   MHD_SC_CONNECTION_ACCEPTED = 10001
    442   ,
    443   /**
    444    * Informational event, thread processing connection terminates.
    445    */
    446   MHD_SC_THREAD_TERMINATING = 10002
    447   ,
    448   /**
    449    * Informational event, state machine status for a connection.
    450    */
    451   MHD_SC_STATE_MACHINE_STATUS_REPORT = 10003
    452   ,
    453   /**
    454    * accept() returned transient error.
    455    */
    456   MHD_SC_ACCEPT_FAILED_EAGAIN = 10004
    457   ,
    458   /**
    459    * Accepted socket is unknown type (probably non-IP).
    460    */
    461   MHD_SC_ACCEPTED_UNKNOWN_TYPE = 10040
    462   ,
    463   /**
    464    * The sockaddr for the accepted socket does not fit the buffer.
    465    * (Strange)
    466    */
    467   MHD_SC_ACCEPTED_SOCKADDR_TOO_LARGE = 10041
    468   ,
    469 
    470   /* 20000-level status codes indicate success of some kind. */
    471 
    472   /**
    473    * MHD is closing a connection after the client closed it
    474    * (perfectly normal end).
    475    */
    476   MHD_SC_CONNECTION_CLOSED = 20000
    477   ,
    478   /**
    479    * MHD is closing a connection because the application
    480    * logic to generate the response data completed.
    481    */
    482   MHD_SC_APPLICATION_DATA_GENERATION_FINISHED = 20001
    483   ,
    484   /**
    485    * The request does not contain a particular type of Authentication
    486    * credentials
    487    */
    488   MHD_SC_AUTH_ABSENT = 20060
    489   ,
    490 
    491   /* 30000-level status codes indicate transient failures
    492      that might go away if the client tries again. */
    493 
    494 
    495   /**
    496    * Resource limit in terms of number of parallel connections
    497    * hit.
    498    */
    499   MHD_SC_LIMIT_CONNECTIONS_REACHED = 30000
    500   ,
    501   /**
    502    * The operation failed because the respective
    503    * daemon is already too deep inside of the shutdown
    504    * activity.
    505    */
    506   MHD_SC_DAEMON_ALREADY_SHUTDOWN = 30020
    507   ,
    508   /**
    509    * Failed to start new thread because of system limits.
    510    */
    511   MHD_SC_CONNECTION_THREAD_SYS_LIMITS_REACHED = 30030
    512   ,
    513   /**
    514    * Failed to start a thread.
    515    */
    516   MHD_SC_CONNECTION_THREAD_LAUNCH_FAILURE = 30031
    517   ,
    518   /**
    519    * The operation failed because we either have no
    520    * listen socket or were already quiesced.
    521    */
    522   MHD_SC_DAEMON_ALREADY_QUIESCED = 30040
    523   ,
    524   /**
    525    * The operation failed because client disconnected
    526    * faster than we could accept().
    527    */
    528   MHD_SC_ACCEPT_FAST_DISCONNECT = 30040
    529   ,
    530   /**
    531    * Operating resource limits hit on accept().
    532    */
    533   MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED = 30060
    534   ,
    535   /**
    536    * Connection was refused by accept policy callback.
    537    */
    538   MHD_SC_ACCEPT_POLICY_REJECTED = 30070
    539   ,
    540   /**
    541    * Failed to allocate memory for the daemon resources.
    542    * TODO: combine similar error codes for daemon
    543    */
    544   MHD_SC_DAEMON_MEM_ALLOC_FAILURE = 30081
    545   ,
    546   /**
    547    * We failed to allocate memory for the connection.
    548    * (May be transient.)
    549    */
    550   MHD_SC_CONNECTION_MEM_ALLOC_FAILURE = 30082
    551   ,
    552   /**
    553    * We failed to allocate memory for the connection's memory pool.
    554    * (May be transient.)
    555    */
    556   MHD_SC_POOL_MEM_ALLOC_FAILURE = 30083
    557   ,
    558   /**
    559    * We failed to allocate memory for the HTTP/2 connection's resources.
    560    * (May be transient.)
    561    */
    562   MHD_SC_H2_CONN_MEM_ALLOC_FAILURE = 30084
    563   ,
    564   /**
    565    * We failed to forward data from a Web socket to the
    566    * application to the remote side due to the socket
    567    * being closed prematurely. (May be transient.)
    568    */
    569   MHD_SC_UPGRADE_FORWARD_INCOMPLETE = 30100
    570   ,
    571   /**
    572    * Failed to allocate memory from our memory pool for processing
    573    * the request.  Likely the request fields are too large to leave
    574    * enough room.
    575    */
    576   MHD_SC_CONNECTION_POOL_NO_MEM_REQ = 30130
    577   ,
    578   /**
    579    * Failed to allocate memory from our memory pool to store GET parameter.
    580    * Likely the request URI or header fields are too large to leave enough room.
    581    */
    582   MHD_SC_CONNECTION_POOL_NO_MEM_GET_PARAM = 30131
    583   ,
    584   /**
    585    * Failed to allocate memory from our memory pool to store parsed cookie.
    586    */
    587   MHD_SC_CONNECTION_POOL_NO_MEM_COOKIE = 30132
    588   ,
    589   /**
    590    * Failed to allocate memory from connection memory pool to store
    591    * parsed Authentication data.
    592    */
    593   MHD_SC_CONNECTION_POOL_NO_MEM_AUTH_DATA = 30133
    594   ,
    595   /**
    596    * Detected jump back of system clock
    597    */
    598   MHD_SC_SYS_CLOCK_JUMP_BACK_LARGE = 30140
    599   ,
    600   /**
    601    * Detected correctable jump back of system clock
    602    */
    603   MHD_SC_SYS_CLOCK_JUMP_BACK_CORRECTED = 30141
    604   ,
    605   /**
    606    * Timeout waiting for communication operation for HTTP-Upgraded connection
    607    */
    608   MHD_SC_UPGRADED_NET_TIMEOUT = 30161
    609   ,
    610   /**
    611    * Not enough system resources
    612    */
    613   MHD_SC_NO_SYS_RESOURCES = 30180
    614   ,
    615 
    616   /* 40000-level errors are caused by the HTTP client
    617      (or the network) */
    618 
    619   /**
    620    * MHD is closing a connection because parsing the
    621    * request failed.
    622    */
    623   MHD_SC_CONNECTION_PARSE_FAIL_CLOSED = 40000
    624   ,
    625   /**
    626    * MHD is returning an error because the header provided
    627    * by the client is too big.
    628    */
    629   MHD_SC_CLIENT_HEADER_TOO_BIG = 40020
    630   ,
    631   /**
    632    * An HTTP/1.1 request was sent without the "Host:" header.
    633    */
    634   MHD_SC_HOST_HEADER_MISSING = 40060
    635   ,
    636   /**
    637    * Request has more than one "Host:" header.
    638    */
    639   MHD_SC_HOST_HEADER_SEVERAL = 40061
    640   ,
    641   /**
    642    * The value of the "Host:" header is invalid.
    643    */
    644   MHD_SC_HOST_HEADER_MALFORMED = 40062
    645   ,
    646   /**
    647    * The given content length was not a number.
    648    */
    649   MHD_SC_CONTENT_LENGTH_MALFORMED = 40065
    650   ,
    651   /**
    652    * Request has more than one "Content-Length:" header with the same value.
    653    */
    654   MHD_SC_CONTENT_LENGTH_SEVERAL_SAME = 40066
    655   ,
    656   /**
    657    * Request has more than one "Content-Length:" header with the different
    658    * values.
    659    */
    660   MHD_SC_CONTENT_LENGTH_SEVERAL_DIFFERENT = 40067
    661   ,
    662   /**
    663    * The BOTH Content-Length and Transfer-Encoding headers are used.
    664    */
    665   MHD_SC_CONTENT_LENGTH_AND_TR_ENC = 40068
    666   ,
    667   /**
    668    * The Content-Length is too large to be handled.
    669    */
    670   MHD_SC_CONTENT_LENGTH_TOO_LARGE = 40069
    671   ,
    672   /**
    673    * Transfer encoding in request is unsupported or invalid.
    674    */
    675   MHD_SC_TRANSFER_ENCODING_UNSUPPORTED = 40075
    676   ,
    677   /**
    678    * "Expect:" value in request is unsupported or invalid.
    679    */
    680   MHD_SC_EXPECT_HEADER_VALUE_UNSUPPORTED = 40076
    681   ,
    682   /**
    683    * The given uploaded, chunked-encoded body was malformed.
    684    */
    685   MHD_SC_CHUNKED_ENCODING_MALFORMED = 40080
    686   ,
    687   /**
    688    * The first header line has whitespace at the start
    689    */
    690   MHD_SC_REQ_FIRST_HEADER_LINE_SPACE_PREFIXED = 40100
    691   ,
    692   /**
    693    * The request target (URI) has whitespace character
    694    */
    695   MHD_SC_REQ_TARGET_HAS_WHITESPACE = 40101
    696   ,
    697   /**
    698    * Wrong bare CR characters has been replaced with space.
    699    */
    700   MHD_SC_REQ_HEADER_CR_REPLACED = 40120
    701   ,
    702   /**
    703    * Header line has not colon and skipped.
    704    */
    705   MHD_SC_REQ_HEADER_LINE_NO_COLON = 40121
    706   ,
    707   /**
    708    * Wrong bare CR characters has been replaced with space.
    709    */
    710   MHD_SC_REQ_FOOTER_CR_REPLACED = 40140
    711   ,
    712   /**
    713    * Footer line has not colon and skipped.
    714    */
    715   MHD_SC_REQ_FOOTER_LINE_NO_COLON = 40141
    716   ,
    717   /**
    718    * The request is malformed.
    719    */
    720   MHD_SC_REQ_MALFORMED = 40155
    721   ,
    722   /**
    723    * The cookie string has been parsed, but it is not fully compliant with
    724    * specifications
    725    */
    726   MHD_SC_REQ_COOKIE_PARSED_NOT_COMPLIANT = 40160
    727   ,
    728   /**
    729    * The cookie string has been parsed only partially
    730    */
    731   MHD_SC_REQ_COOKIE_PARSED_PARTIALLY = 40161
    732   ,
    733   /**
    734    * The cookie string is ignored, as it is not fully compliant with
    735    * specifications
    736    */
    737   MHD_SC_REQ_COOKIE_IGNORED_NOT_COMPLIANT = 40162
    738   ,
    739   /**
    740    * The cookie string has been ignored as it is invalid
    741    */
    742   MHD_SC_REQ_COOKIE_INVALID = 40163
    743   ,
    744   /**
    745    * The POST data parsed successfully, but has missing or incorrect
    746    * termination.
    747    * The last parsed field may have incorrect data.
    748    */
    749   MHD_SC_REQ_POST_PARSE_OK_BAD_TERMINATION = 40202
    750   ,
    751   /**
    752    * Parsing of the POST data is incomplete because client used incorrect
    753    * format of POST encoding.
    754    * Some POST data is available or has been provided via callback.
    755    */
    756   MHD_SC_REQ_POST_PARSE_PARTIAL_INVALID_POST_FORMAT = 40203
    757   ,
    758   /**
    759    * The request does not have "Content-Type:" header and POST data cannot
    760    * be parsed
    761    */
    762   MHD_SC_REQ_POST_PARSE_FAILED_NO_CNTN_TYPE = 40280
    763   ,
    764   /**
    765    * The request has unknown POST encoding specified by "Content-Type:" header
    766    */
    767   MHD_SC_REQ_POST_PARSE_FAILED_UNKNOWN_CNTN_TYPE = 40281
    768   ,
    769   /**
    770    * The request has "Content-Type: multipart/form-data" header without
    771    * "boundary" parameter
    772    */
    773   MHD_SC_REQ_POST_PARSE_FAILED_HEADER_NO_BOUNDARY = 40282
    774   ,
    775   /**
    776    * The request has "Content-Type: multipart/form-data" header with misformed
    777    * data
    778    */
    779   MHD_SC_REQ_POST_PARSE_FAILED_HEADER_MISFORMED = 40283
    780   ,
    781   /**
    782    * The POST data cannot be parsed because client used incorrect format
    783    * of POST encoding.
    784    */
    785   MHD_SC_REQ_POST_PARSE_FAILED_INVALID_POST_FORMAT = 40290
    786   ,
    787   /**
    788    * The data in Auth request header has invalid format.
    789    * For example, for Basic Authentication base64 decoding failed.
    790    */
    791   MHD_SC_REQ_AUTH_DATA_BROKEN = 40320
    792   ,
    793   /**
    794    * The request cannot be processed. Sending error reply.
    795    */
    796   MHD_SC_REQ_PROCCESSING_ERR_REPLY = 41000
    797   ,
    798   /**
    799    * MHD is closing a connection because of timeout.
    800    */
    801   MHD_SC_CONNECTION_TIMEOUT = 42000
    802   ,
    803   /**
    804    * MHD is closing a connection because receiving the
    805    * request failed.
    806    */
    807   MHD_SC_CONNECTION_RECV_FAIL_CLOSED = 42020
    808   ,
    809   /**
    810    * MHD is closing a connection because sending the response failed.
    811    */
    812   MHD_SC_CONNECTION_SEND_FAIL_CLOSED = 42021
    813   ,
    814   /**
    815    * MHD is closing a connection because remote client shut down its sending
    816    * side before full request was sent.
    817    */
    818   MHD_SC_CLIENT_SHUTDOWN_EARLY = 42040
    819   ,
    820   /**
    821    * MHD is closing a connection because remote client closed connection
    822    * early.
    823    */
    824   MHD_SC_CLIENT_CLOSED_CONN_EARLY = 42041
    825   ,
    826   /**
    827    * MHD is closing a connection connection has been (remotely) aborted.
    828    */
    829   MHD_SC_CONNECTION_ABORTED = 42042
    830   ,
    831   /**
    832    * MHD is closing a connection because it was reset.
    833    */
    834   MHD_SC_CONNECTION_RESET = 42060
    835   ,
    836   /**
    837    * MHD is closing a connection connection (or connection socket) has
    838    * been broken.
    839    */
    840   MHD_SC_CONNECTION_BROKEN = 42061
    841   ,
    842   /**
    843    * ALPN in TLS connection selected HTTP/2 (as advertised by the client),
    844    * but the client did not send a valid HTTP/2 connection preface.
    845    */
    846   MHD_SC_ALPN_H2_NO_PREFACE = 43001
    847   ,
    848 
    849   /* 50000-level errors are because of an error internal
    850      to the MHD logic, possibly including our interaction
    851      with the operating system (but not the application) */
    852 
    853   /**
    854    * This build of MHD does not support TLS, but the application
    855    * requested TLS.
    856    */
    857   MHD_SC_TLS_DISABLED = 50000
    858   ,
    859   /**
    860    * The selected TLS backend does not yet support this operation.
    861    */
    862   MHD_SC_TLS_BACKEND_OPERATION_UNSUPPORTED = 50004
    863   ,
    864   /**
    865    * Failed to setup ITC channel.
    866    */
    867   MHD_SC_ITC_INITIALIZATION_FAILED = 50005
    868   ,
    869   /**
    870    * File descriptor for ITC cannot be used because the FD number is higher
    871    * than the limit set by FD_SETSIZE (if internal polling with select is used)
    872    * or by application.
    873    */
    874   MHD_SC_ITC_FD_OUTSIDE_OF_SET_RANGE = 50006
    875   ,
    876   /**
    877    * The specified value for the NC length is way too large
    878    * for this platform (integer overflow on `size_t`).
    879    */
    880   MHD_SC_DIGEST_AUTH_NC_LENGTH_TOO_BIG = 50010
    881   ,
    882   /**
    883    * We failed to allocate memory for the specified nonce
    884    * counter array.  The option was not set.
    885    */
    886   MHD_SC_DIGEST_AUTH_NC_ALLOCATION_FAILURE = 50011
    887   ,
    888   /**
    889    * This build of the library does not support
    890    * digest authentication.
    891    */
    892   MHD_SC_DIGEST_AUTH_NOT_SUPPORTED_BY_BUILD = 50012
    893   ,
    894   /**
    895    * IPv6 requested but not supported by this build.
    896    * @sa #MHD_SC_AF_NOT_SUPPORTED_BY_BUILD
    897    */
    898   MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD = 50020
    899   ,
    900   /**
    901    * Specified address/protocol family is not supported by this build.
    902    * @sa MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD
    903    */
    904   MHD_SC_AF_NOT_SUPPORTED_BY_BUILD = 50021
    905   ,
    906   /**
    907    * The requested address/protocol family is rejected by the OS.
    908    * @sa #MHD_SC_AF_NOT_SUPPORTED_BY_BUILD
    909    */
    910   MHD_SC_AF_NOT_AVAILABLE = 500022
    911   ,
    912   /**
    913    * We failed to open the listen socket.
    914    */
    915   MHD_SC_FAILED_TO_OPEN_LISTEN_SOCKET = 50040
    916   ,
    917   /**
    918    * Failed to enable listen port reuse.
    919    */
    920   MHD_SC_LISTEN_PORT_REUSE_ENABLE_FAILED = 50041
    921   ,
    922   /**
    923    * Failed to enable listen port reuse.
    924    */
    925   MHD_SC_LISTEN_PORT_REUSE_ENABLE_NOT_SUPPORTED = 50042
    926   ,
    927   /**
    928    * Failed to enable listen address reuse.
    929    */
    930   MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_FAILED = 50043
    931   ,
    932   /**
    933    * Enabling listen address reuse is not supported by this platform.
    934    */
    935   MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_NOT_SUPPORTED = 50044
    936   ,
    937   /**
    938    * Failed to enable exclusive use of listen address.
    939    */
    940   MHD_SC_LISTEN_ADDRESS_EXCLUSIVE_ENABLE_FAILED = 50045
    941   ,
    942   /**
    943    * Dual stack configuration is not possible for provided sockaddr.
    944    */
    945   MHD_SC_LISTEN_DUAL_STACK_NOT_SUITABLE = 50046
    946   ,
    947   /**
    948    * Failed to enable or disable dual stack for the IPv6 listen socket.
    949    * The OS default dual-stack setting is different from what is requested.
    950    */
    951   MHD_SC_LISTEN_DUAL_STACK_CONFIGURATION_REJECTED = 50047
    952   ,
    953   /**
    954    * Failed to enable or disable dual stack for the IPv6 listen socket.
    955    * The socket will be used in whatever the default is the OS uses.
    956    */
    957   MHD_SC_LISTEN_DUAL_STACK_CONFIGURATION_UNKNOWN = 50048
    958   ,
    959   /**
    960    * On this platform, MHD does not support explicitly configuring
    961    * dual stack behaviour.
    962    */
    963   MHD_SC_LISTEN_DUAL_STACK_CONFIGURATION_NOT_SUPPORTED = 50049
    964   ,
    965   /**
    966    * Failed to enable TCP FAST OPEN option.
    967    */
    968   MHD_SC_LISTEN_FAST_OPEN_FAILURE = 50050
    969   ,
    970   /**
    971    * TCP FAST OPEN is not supported by the platform or by this MHD build.
    972    */
    973   MHD_SC_FAST_OPEN_NOT_SUPPORTED = 50051
    974   ,
    975   /**
    976    * We failed to set the listen socket to non-blocking.
    977    */
    978   MHD_SC_LISTEN_SOCKET_NONBLOCKING_FAILURE = 50052
    979   ,
    980   /**
    981    * Failed to configure listen socket to be non-inheritable.
    982    */
    983   MHD_SC_LISTEN_SOCKET_NOINHERIT_FAILED = 50053
    984   ,
    985   /**
    986    * Listen socket FD cannot be used because the FD number is higher than
    987    * the limit set by FD_SETSIZE (if internal polling with select is used) or
    988    * by application.
    989    */
    990   MHD_SC_LISTEN_FD_OUTSIDE_OF_SET_RANGE = 50054
    991   ,
    992   /**
    993    * We failed to bind the listen socket.
    994    */
    995   MHD_SC_LISTEN_SOCKET_BIND_FAILED = 50055
    996   ,
    997   /**
    998    * Failed to start listening on listen socket.
    999    */
   1000   MHD_SC_LISTEN_FAILURE = 50056
   1001   ,
   1002   /**
   1003    * Failed to detect the port number on the listening socket
   1004    */
   1005   MHD_SC_LISTEN_PORT_DETECT_FAILURE = 50057
   1006   ,
   1007   /**
   1008    * We failed to create control socket for the epoll().
   1009    */
   1010   MHD_SC_EPOLL_CTL_CREATE_FAILED = 50060
   1011   ,
   1012   /**
   1013    * We failed to configure control socket for the epoll()
   1014    * to be non-inheritable.
   1015    */
   1016   MHD_SC_EPOLL_CTL_CONFIGURE_NOINHERIT_FAILED = 50061
   1017   ,
   1018   /**
   1019    * The epoll() control FD cannot be used because the FD number is higher
   1020    * than the limit set by application.
   1021    */
   1022   MHD_SC_EPOLL_CTL_OUTSIDE_OF_SET_RANGE = 50062
   1023   ,
   1024   /**
   1025    * Failed to allocate memory for daemon's events data, like fd_sets,
   1026    * poll, epoll or kqueue structures.
   1027    */
   1028   MHD_SC_EVENTS_MEMORY_ALLOCATE_FAILURE = 50063
   1029   ,
   1030   /**
   1031    * Failed to add daemon's FDs (ITC and/or listening) to the internal events
   1032    * monitoring
   1033    */
   1034   MHD_SC_EVENTS_REG_DAEMON_FDS_FAILURE = 50065
   1035   ,
   1036   /**
   1037    * Failed to register daemon's FDs (ITC or listening) in the application
   1038    * (external event) monitoring
   1039    */
   1040   MHD_SC_EXT_EVENT_REG_DAEMON_FDS_FAILURE = 50066
   1041   ,
   1042   /**
   1043    * Failed to create kqueue FD
   1044    */
   1045   MHD_SC_KQUEUE_FD_CREATE_FAILED = 50067
   1046   ,
   1047   /**
   1048    * Failed to configure kqueue FD to be non-inheritable.
   1049    */
   1050   MHD_SC_KQUEUE_FD_SET_NOINHERIT_FAILED = 50068
   1051   ,
   1052   /**
   1053    * The kqueue FD cannot be used because the FD number is higher
   1054    * than the limit set by application.
   1055    */
   1056   MHD_SC_KQUEUE_FD_OUTSIDE_OF_SET_RANGE = 50069
   1057   ,
   1058   /**
   1059    * The select() syscall is not available on this platform or in this MHD
   1060    * build.
   1061    */
   1062   MHD_SC_SELECT_SYSCALL_NOT_AVAILABLE = 50070
   1063   ,
   1064   /**
   1065    * The poll() syscall is not available on this platform or in this MHD
   1066    * build.
   1067    */
   1068   MHD_SC_POLL_SYSCALL_NOT_AVAILABLE = 50071
   1069   ,
   1070   /**
   1071    * The epoll syscalls are not available on this platform or in this MHD
   1072    * build.
   1073    */
   1074   MHD_SC_EPOLL_SYSCALL_NOT_AVAILABLE = 50072
   1075   ,
   1076   /**
   1077    * The kqueue syscalls are not available on this platform or in this MHD
   1078    * build.
   1079    */
   1080   MHD_SC_KQUEUE_SYSCALL_NOT_AVAILABLE = 50073
   1081   ,
   1082   /**
   1083    * Failed to obtain our listen port via introspection.
   1084    * FIXME: remove?
   1085    */
   1086   MHD_SC_LISTEN_PORT_INTROSPECTION_FAILURE = 50080
   1087   ,
   1088   /**
   1089    * Failed to obtain our listen port via introspection
   1090    * due to unsupported address family being used.
   1091    */
   1092   MHD_SC_LISTEN_PORT_INTROSPECTION_UNKNOWN_AF = 50081
   1093   ,
   1094   /**
   1095    * Failed to initialise mutex.
   1096    */
   1097   MHD_SC_MUTEX_INIT_FAILURE = 50085
   1098   ,
   1099   /**
   1100    * Failed to allocate memory for the thread pool.
   1101    */
   1102   MHD_SC_THREAD_POOL_MEM_ALLOC_FAILURE = 50090
   1103   ,
   1104   /**
   1105    * We failed to allocate mutex for thread pool worker.
   1106    */
   1107   MHD_SC_THREAD_POOL_CREATE_MUTEX_FAILURE = 50093
   1108   ,
   1109   /**
   1110    * Failed to start the main daemon thread.
   1111    */
   1112   MHD_SC_THREAD_MAIN_LAUNCH_FAILURE = 50095
   1113   ,
   1114   /**
   1115    * Failed to start the daemon thread for listening.
   1116    */
   1117   MHD_SC_THREAD_LISTENING_LAUNCH_FAILURE = 50096
   1118   ,
   1119   /**
   1120    * Failed to start the worker thread for the thread pool.
   1121    */
   1122   MHD_SC_THREAD_WORKER_LAUNCH_FAILURE = 50097
   1123   ,
   1124   /**
   1125    * There was an attempt to upgrade a connection on
   1126    * a daemon where upgrades are disallowed.
   1127    */
   1128   MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED = 50100
   1129   ,
   1130   /**
   1131    * Failed to signal via ITC channel.
   1132    */
   1133   MHD_SC_ITC_USE_FAILED = 500101
   1134   ,
   1135   /**
   1136    * Failed to check for the signal on the ITC channel.
   1137    */
   1138   MHD_SC_ITC_CHECK_FAILED = 500102
   1139   ,
   1140   /**
   1141    * System reported error conditions on the ITC FD.
   1142    */
   1143   MHD_SC_ITC_STATUS_ERROR = 500104
   1144   ,
   1145   /**
   1146    * Failed to add a socket to the epoll set.
   1147    */
   1148   MHD_SC_EPOLL_CTL_ADD_FAILED = 500110
   1149   ,
   1150   /**
   1151    * Socket FD cannot be used because the FD number is higher than the limit set
   1152    * by FD_SETSIZE (if internal polling with select is used) or by application.
   1153    */
   1154   MHD_SC_SOCKET_OUTSIDE_OF_SET_RANGE = 500111
   1155   ,
   1156   /**
   1157    * The daemon cannot be started with the specified settings as no space
   1158    * left for the connections sockets within limits set by FD_SETSIZE.
   1159    * Consider use another sockets polling syscall (only select() has such
   1160    * limitations)
   1161    */
   1162   MHD_SC_SYS_FD_SETSIZE_TOO_STRICT = 50112
   1163   ,
   1164   /**
   1165    * This daemon was not configured with options that
   1166    * would allow us to obtain a meaningful timeout.
   1167    */
   1168   MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_TIMEOUT = 50113
   1169   ,
   1170   /**
   1171    * This daemon was not configured with options that
   1172    * would allow us to run with select() data.
   1173    */
   1174   MHD_SC_CONFIGURATION_MISMATCH_FOR_RUN_SELECT = 50114
   1175   ,
   1176   /**
   1177    * This daemon was not configured to run with an
   1178    * external event loop.
   1179    */
   1180   MHD_SC_CONFIGURATION_MISMATCH_FOR_RUN_EXTERNAL = 50115
   1181   ,
   1182   /**
   1183    * Encountered an unexpected error from select()
   1184    * (should never happen).
   1185    */
   1186   MHD_SC_UNEXPECTED_SELECT_ERROR = 50116
   1187   ,
   1188   /**
   1189    * Failed to remove a connection socket to the epoll or kqueue monitoring.
   1190    */
   1191   MHD_SC_EVENTS_CONN_REMOVE_FAILED = 50117
   1192   ,
   1193   /**
   1194    * poll() is not supported.
   1195    */
   1196   MHD_SC_POLL_NOT_SUPPORTED = 50120
   1197   ,
   1198   /**
   1199    * Encountered a (potentially) recoverable error from poll().
   1200    */
   1201   MHD_SC_POLL_SOFT_ERROR = 50121
   1202   ,
   1203   /**
   1204    * Encountered an unrecoverable error from poll().
   1205    */
   1206   MHD_SC_POLL_HARD_ERROR = 50122
   1207   ,
   1208   /**
   1209    * Encountered a (potentially) recoverable error from select().
   1210    */
   1211   MHD_SC_SELECT_SOFT_ERROR = 50123
   1212   ,
   1213   /**
   1214    * Encountered an unrecoverable error from select().
   1215    */
   1216   MHD_SC_SELECT_HARD_ERROR = 50124
   1217   ,
   1218   /**
   1219    * System reported error conditions on the listening socket.
   1220    */
   1221   MHD_SC_LISTEN_STATUS_ERROR = 50129
   1222   ,
   1223   /**
   1224    * Encountered an unrecoverable error from epoll function.
   1225    */
   1226   MHD_SC_EPOLL_HARD_ERROR = 50130
   1227   ,
   1228   /**
   1229    * Encountered an unrecoverable error from kevent() function.
   1230    */
   1231   MHD_SC_KQUEUE_HARD_ERROR = 50131
   1232   ,
   1233   /**
   1234    * We failed to configure accepted socket
   1235    * to not use a SIGPIPE.
   1236    */
   1237   MHD_SC_ACCEPT_CONFIGURE_NOSIGPIPE_FAILED = 50140
   1238   ,
   1239   /**
   1240    * We failed to configure accepted socket
   1241    * to be non-inheritable.
   1242    */
   1243   MHD_SC_ACCEPT_CONFIGURE_NOINHERIT_FAILED = 50141
   1244   ,
   1245   /**
   1246    * We failed to configure accepted socket
   1247    * to be non-blocking.
   1248    */
   1249   MHD_SC_ACCEPT_CONFIGURE_NONBLOCKING_FAILED = 50142
   1250   ,
   1251   /**
   1252    * The accepted socket FD value is too large.
   1253    */
   1254   MHD_SC_ACCEPT_OUTSIDE_OF_SET_RANGE = 50143
   1255   ,
   1256   /**
   1257    * accept() returned unexpected error.
   1258    */
   1259   MHD_SC_ACCEPT_FAILED_UNEXPECTEDLY = 50144
   1260   ,
   1261   /**
   1262    * Operating resource limits hit on accept() while
   1263    * zero connections are active. Oopsie.
   1264    */
   1265   MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED_INSTANTLY = 50145
   1266   ,
   1267   /**
   1268    * The daemon sockets polling mode requires non-blocking sockets.
   1269    */
   1270   MHD_SC_NONBLOCKING_REQUIRED = 50146
   1271   ,
   1272   /**
   1273    * Encountered an unexpected error from epoll_wait()
   1274    * (should never happen).
   1275    */
   1276   MHD_SC_UNEXPECTED_EPOLL_WAIT_ERROR = 50150
   1277   ,
   1278   /**
   1279    * epoll file descriptor is invalid (strange)
   1280    */
   1281   MHD_SC_EPOLL_FD_INVALID = 50151
   1282   ,
   1283   /**
   1284    * Unexpected socket error (strange)
   1285    */
   1286   MHD_SC_UNEXPECTED_SOCKET_ERROR = 50152
   1287   ,
   1288   /**
   1289    * Failed to add IP address to per-IP counter for
   1290    * some reason.
   1291    */
   1292   MHD_SC_IP_COUNTER_FAILURE = 50160
   1293   ,
   1294   /**
   1295    * Application violated our API by calling shutdown
   1296    * while having an upgrade connection still open.
   1297    */
   1298   MHD_SC_SHUTDOWN_WITH_OPEN_UPGRADED_CONNECTION = 50180
   1299   ,
   1300   /**
   1301    * Due to an unexpected internal error with the
   1302    * state machine, we closed the connection.
   1303    */
   1304   MHD_SC_STATEMACHINE_FAILURE_CONNECTION_CLOSED = 50200
   1305   ,
   1306   /**
   1307    * Failed to allocate memory in connection's pool
   1308    * to parse the cookie header.
   1309    */
   1310   MHD_SC_COOKIE_POOL_ALLOCATION_FAILURE = 50220
   1311   ,
   1312   /**
   1313    * MHD failed to build the response header.
   1314    */
   1315   MHD_SC_REPLY_FAILED_HEADER_GENERATION = 50230
   1316   ,
   1317   /**
   1318    * Failed to allocate memory in connection's pool for the reply.
   1319    */
   1320   MHD_SC_REPLY_POOL_ALLOCATION_FAILURE = 50231
   1321   ,
   1322   /**
   1323    * Failed to read the file for file-backed response.
   1324    */
   1325   MHD_SC_REPLY_FILE_READ_ERROR = 50232
   1326   ,
   1327   /**
   1328    * Failed to generate the nonce for the Digest Auth.
   1329    */
   1330   MHD_SC_REPLY_NONCE_ERROR = 50233
   1331   ,
   1332   /**
   1333    * MHD refused to add duplicate DATE header.
   1334    */
   1335   MHD_SC_DATE_HEADER_SEVERAL = 50234
   1336   ,
   1337   /**
   1338    * MHD refused to add duplicate CONNECTION header.
   1339    */
   1340   MHD_SC_CONNECTION_HEADER_SEVERAL = 50345
   1341   ,
   1342   /**
   1343    * Failed to allocate memory in connection's pool for the reply.
   1344    */
   1345   MHD_SC_ERR_RESPONSE_ALLOCATION_FAILURE = 50250
   1346   ,
   1347   /**
   1348    * The request POST data cannot be parsed because stream has not enough
   1349    * pool memory free.
   1350    */
   1351   MHD_SC_REQ_POST_PARSE_FAILED_NO_POOL_MEM = 50260
   1352   ,
   1353   /**
   1354    * The POST data cannot be parsed completely because no "large shared buffer"
   1355    * space is available.
   1356    * Some POST data may be parsed.
   1357    */
   1358   MHD_SC_REQ_POST_PARSE_FAILED_NO_LARGE_BUF_MEM = 50261
   1359   ,
   1360   /**
   1361    * The application set POST encoding to "multipart/form-data", but the request
   1362    * has no "Content-Type: multipart/form-data" header which is required
   1363    * to find "boundary" used in this encoding
   1364    */
   1365   MHD_SC_REQ_POST_PARSE_FAILED_HEADER_NOT_MPART = 50284
   1366   ,
   1367   /**
   1368    * The feature is not supported by this MHD build (either
   1369    * disabled by configure parameters or build platform
   1370    * did not support it, because headers are missing or
   1371    * so kernel does not have such feature).
   1372    * The feature will not be enabled if the same MHD binary
   1373    * will be run on another kernel, computer or system
   1374    * configuration.
   1375    */
   1376   MHD_SC_FEATURE_DISABLED = 50300
   1377   ,
   1378   /**
   1379    * The feature is not supported by this platform, while
   1380    * supported by MHD build.
   1381    * The feature can be enabled by changing the kernel or
   1382    * running on another computer or with other system
   1383    * configuration.
   1384    */
   1385   MHD_SC_FEATURE_NOT_AVAILABLE = 50320
   1386   ,
   1387   /**
   1388    * Failed to stop the thread
   1389    */
   1390   MHD_SC_DAEMON_THREAD_STOP_ERROR = 50350
   1391   ,
   1392   /**
   1393    * Unexpected reasons for thread stop
   1394    */
   1395   MHD_SC_DAEMON_THREAD_STOP_UNEXPECTED = 50351
   1396   ,
   1397   /**
   1398    * Daemon system data is broken (like listen socket was unexpectedly closed).
   1399    * The daemon needs to be closed.
   1400    * A new daemon can be started as a replacement after closing the current
   1401    * daemon.
   1402    */
   1403   MHD_SC_DAEMON_SYS_DATA_BROKEN = 50370
   1404   ,
   1405   /**
   1406    * Failed to acquire response mutex lock
   1407    */
   1408   MHD_SC_RESPONSE_MUTEX_LOCK_FAILED = 50500
   1409   ,
   1410   /**
   1411    * Failed to initialise response mutex
   1412    */
   1413   MHD_SC_RESPONSE_MUTEX_INIT_FAILED = 50501
   1414   ,
   1415   /**
   1416    * Unable to clear "reusable" flag.
   1417    * One this flag set, it cannot be removed for the response lifetime.
   1418    */
   1419   MHD_SC_RESPONSE_CANNOT_CLEAR_REUSE = 50520
   1420   ,
   1421   /**
   1422    * Unable to allocate memory for the response header
   1423    */
   1424   MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED = 50540
   1425   ,
   1426   /**
   1427    * Failed to switch TCP_NODELAY option for the socket
   1428    */
   1429   MHD_SC_SOCKET_TCP_NODELAY_FAILED = 50600
   1430   ,
   1431   /**
   1432    * Failed to switch TCP_CORK or TCP_NOPUSH option for the socket
   1433    */
   1434   MHD_SC_SOCKET_TCP_CORK_NOPUSH_FAILED = 50601
   1435   ,
   1436   /**
   1437    * Failed to force flush the last part of the response header or
   1438    * the response content
   1439    */
   1440   MHD_SC_SOCKET_FLUSH_LAST_PART_FAILED = 50620
   1441   ,
   1442   /**
   1443    * Failed to push buffered data by zero-sized send()
   1444    */
   1445   MHD_SC_SOCKET_ZERO_SEND_FAILED = 50621
   1446   ,
   1447   /**
   1448    * The HTTP-Upgraded network connection has been closed / disconnected
   1449    */
   1450   MHD_SC_UPGRADED_NET_CONN_CLOSED = 50800
   1451   ,
   1452   /**
   1453    * The HTTP-Upgraded network connection has been broken
   1454    */
   1455   MHD_SC_UPGRADED_NET_CONN_BROKEN = 50801
   1456   ,
   1457   /**
   1458    * The TLS communication error on HTTP-Upgraded connection
   1459    */
   1460   MHD_SC_UPGRADED_TLS_ERROR = 50801
   1461   ,
   1462   /**
   1463    * Unrecoverable sockets communication error on HTTP-Upgraded connection
   1464    */
   1465   MHD_SC_UPGRADED_NET_HARD_ERROR = 50840
   1466   ,
   1467   /**
   1468    * MHD cannot wait for the data on the HTTP-Upgraded connection, because
   1469    * current build or the platform does not support required functionality.
   1470    * Communication with zero timeout is fully supported.
   1471    */
   1472   MHD_SC_UPGRADED_WAITING_NOT_SUPPORTED = 50840
   1473   ,
   1474   /**
   1475    * Global initialisation of MHD library failed
   1476    */
   1477   MHD_SC_LIB_INIT_GLOBAL_FAILED = 51000
   1478   ,
   1479   /**
   1480    * Failed to initialise TLS context for the daemon
   1481    */
   1482   MHD_SC_TLS_DAEMON_INIT_FAILED = 51200
   1483   ,
   1484   /**
   1485    * Failed to initialise TLS context for the new connection
   1486    */
   1487   MHD_SC_TLS_CONNECTION_INIT_FAILED = 51201
   1488   ,
   1489   /**
   1490    * Warning about TLS backend configuration
   1491    */
   1492   MHD_SC_TLS_LIB_CONF_WARNING = 51202
   1493   ,
   1494   /**
   1495    * Failed to perform TLS handshake
   1496    */
   1497   MHD_SC_TLS_CONNECTION_HANDSHAKED_FAILED = 51220
   1498   ,
   1499   /**
   1500    * Hashing failed.
   1501    * Internal hashing function can never fail (and this code is never returned
   1502    * for them). External hashing function (like TLS backend-based) may fail
   1503    * for various reasons, like failure of hardware acccelerated hashing.
   1504    */
   1505   MHD_SC_HASH_FAILED = 51260
   1506   ,
   1507   /**
   1508    * Something wrong in the internal MHD logic.
   1509    * This error should be never returned if MHD works as expected.
   1510    * If this code is ever returned, please report to MHD maintainers.
   1511    */
   1512   MHD_SC_INTERNAL_ERROR = 59900
   1513   ,
   1514 
   1515   /* 60000-level errors are because the application
   1516      logic did something wrong or generated an error. */
   1517 
   1518   /**
   1519    * The application called function too early.
   1520    * For example, a header value was requested before the headers
   1521    * had been received.
   1522    */
   1523   MHD_SC_TOO_EARLY = 60000
   1524   ,
   1525   /**
   1526    * The application called this function too late.
   1527    * For example, MHD has already started sending reply.
   1528    */
   1529   MHD_SC_TOO_LATE = 60001
   1530   ,
   1531   /**
   1532    * MHD does not support the requested combination of
   1533    * the sockets polling syscall and the work mode.
   1534    */
   1535   MHD_SC_SYSCALL_WORK_MODE_COMBINATION_INVALID = 60010
   1536   ,
   1537   /**
   1538    * MHD does not support quiescing if ITC was disabled
   1539    * and threads are used.
   1540    */
   1541   MHD_SC_SYSCALL_QUIESCE_REQUIRES_ITC = 60011
   1542   ,
   1543   /**
   1544    * The option provided or function called can be used only with "external
   1545    * events" modes.
   1546    */
   1547   MHD_SC_EXTERNAL_EVENT_ONLY = 60012
   1548   ,
   1549   /**
   1550    * MHD is closing a connection because the application
   1551    * logic to generate the response data failed.
   1552    */
   1553   MHD_SC_APPLICATION_DATA_GENERATION_FAILURE_CLOSED = 60015
   1554   ,
   1555   /**
   1556    * MHD is closing a connection because the application
   1557    * callback told it to do so.
   1558    */
   1559   MHD_SC_APPLICATION_CALLBACK_ABORT_ACTION = 60016
   1560   ,
   1561   /**
   1562    * Application only partially processed upload and did
   1563    * not suspend connection. This may result in a hung
   1564    * connection.
   1565    */
   1566   MHD_SC_APPLICATION_HUNG_CONNECTION = 60017
   1567   ,
   1568   /**
   1569    * Application only partially processed upload and did
   1570    * not suspend connection and the read buffer was maxxed
   1571    * out, so MHD closed the connection.
   1572    */
   1573   MHD_SC_APPLICATION_HUNG_CONNECTION_CLOSED = 60018
   1574   ,
   1575   /**
   1576    * Attempted to set an option that conflicts with another option
   1577    * already set.
   1578    */
   1579   MHD_SC_OPTIONS_CONFLICT = 60020
   1580   ,
   1581   /**
   1582    * Attempted to set an option that not recognised by MHD.
   1583    */
   1584   MHD_SC_OPTION_UNKNOWN = 60021
   1585   ,
   1586   /**
   1587    * Parameter specified unknown work mode.
   1588    */
   1589   MHD_SC_CONFIGURATION_UNEXPECTED_WM = 60022
   1590   ,
   1591   /**
   1592    * Parameter specified unknown Sockets Polling Syscall (SPS).
   1593    */
   1594   MHD_SC_CONFIGURATION_UNEXPECTED_SPS = 60023
   1595   ,
   1596   /**
   1597    * The size of the provided sockaddr does not match address family.
   1598    */
   1599   MHD_SC_CONFIGURATION_WRONG_SA_SIZE = 60024
   1600   ,
   1601   /**
   1602    * The number set by #MHD_D_O_FD_NUMBER_LIMIT is too strict to run
   1603    * the daemon
   1604    */
   1605   MHD_SC_MAX_FD_NUMBER_LIMIT_TOO_STRICT = 60025
   1606   ,
   1607   /**
   1608    * The number set by #MHD_D_O_GLOBAL_CONNECTION_LIMIT is too for the daemon
   1609    * configuration
   1610    */
   1611   MHD_SC_CONFIGURATION_CONN_LIMIT_TOO_SMALL = 60026
   1612   ,
   1613   /**
   1614    * The provided configuration parameter is NULL, but it must be non-NULL
   1615    */
   1616   MHD_SC_CONFIGURATION_PARAM_NULL = 60027
   1617   ,
   1618   /**
   1619    * The size of the provided configuration parameter is too large
   1620    */
   1621   MHD_SC_CONFIGURATION_PARAM_TOO_LARGE = 60028
   1622   ,
   1623   /**
   1624    * The application requested an unsupported TLS backend to be used.
   1625    */
   1626   MHD_SC_TLS_BACKEND_UNSUPPORTED = 60030
   1627   ,
   1628   /**
   1629    * The application attempted to setup TLS parameters before
   1630    * enabling TLS.
   1631    */
   1632   MHD_SC_TLS_BACKEND_UNINITIALIZED = 60031
   1633   ,
   1634   /**
   1635    * The application requested a TLS backend which cannot be used due
   1636    * to missing TLS dynamic library or backend initialisation problem.
   1637    */
   1638   MHD_SC_TLS_BACKEND_UNAVAILABLE = 60032
   1639   ,
   1640   /**
   1641    * Provided TLS certificate and/or private key are incorrect
   1642    */
   1643   MHD_SC_TLS_CONF_BAD_CERT = 60033
   1644   ,
   1645   /**
   1646    * The application requested a daemon setting that cannot be used with
   1647    * selected TLS backend
   1648    */
   1649   MHD_SC_TLS_BACKEND_DAEMON_INCOMPATIBLE_SETTINGS = 60034
   1650   ,
   1651   /**
   1652    * The response header name has forbidden characters or token
   1653    */
   1654   MHD_SC_RESP_HEADER_NAME_INVALID = 60050
   1655   ,
   1656   /**
   1657    * The response header value has forbidden characters or token
   1658    */
   1659   MHD_SC_RESP_HEADER_VALUE_INVALID = 60051
   1660   ,
   1661   /**
   1662    * An attempt to add header conflicting with other response header
   1663    */
   1664   MHD_SC_RESP_HEADERS_CONFLICT = 60052
   1665   ,
   1666   /**
   1667    * The pointer to the response object is NULL
   1668    */
   1669   MHD_SC_RESP_POINTER_NULL = 60060
   1670   ,
   1671   /**
   1672    * The response HTTP status code is not suitable
   1673    */
   1674   MHD_SC_RESP_HTTP_CODE_NOT_SUITABLE = 60061
   1675   ,
   1676   /**
   1677    * The provided MHD_Action is invalid
   1678    */
   1679   MHD_SC_ACTION_INVALID = 60080
   1680   ,
   1681   /**
   1682    * The provided MHD_UploadAction is invalid
   1683    */
   1684   MHD_SC_UPLOAD_ACTION_INVALID = 60081
   1685   ,
   1686   /**
   1687    * The provided Dynamic Content Creator action is invalid
   1688    */
   1689   MHD_SC_DCC_ACTION_INVALID = 60082
   1690   ,
   1691   /**
   1692    * The response must be empty
   1693    */
   1694   MHD_SC_REPLY_NOT_EMPTY_RESPONSE = 60101
   1695   ,
   1696   /**
   1697    * The "Content-Length" header is not allowed in the reply
   1698    */
   1699   MHD_SC_REPLY_CONTENT_LENGTH_NOT_ALLOWED = 60102
   1700   ,
   1701   /**
   1702    * The provided reply headers do not fit the connection buffer
   1703    */
   1704   MHD_SC_REPLY_HEADERS_TOO_LARGE = 60103
   1705   ,
   1706   /**
   1707    * Specified offset in file-backed response is too large and not supported
   1708    * by the platform
   1709    */
   1710   MHD_SC_REPLY_FILE_OFFSET_TOO_LARGE = 60104
   1711   ,
   1712   /**
   1713    * File-backed response has file smaller than specified combination of
   1714    * the file offset and the response size.
   1715    */
   1716   MHD_SC_REPLY_FILE_TOO_SHORT = 60105
   1717   ,
   1718   /**
   1719    * The new connection cannot be used because the FD number is higher than
   1720    * the limit set by FD_SETSIZE (if internal polling with select is used) or
   1721    * by application.
   1722    */
   1723   MHD_SC_NEW_CONN_FD_OUTSIDE_OF_SET_RANGE = 60140
   1724   ,
   1725   /**
   1726    * The daemon is being destroyed, while not all HTTP-Upgraded connections
   1727    * has been closed.
   1728    */
   1729   MHD_SC_DAEMON_DESTROYED_WITH_UNCLOSED_UPGRADED = 60160
   1730   ,
   1731   /**
   1732    * The provided pointer to 'struct MHD_UpgradedHandle' is invalid
   1733    */
   1734   MHD_SC_UPGRADED_HANDLE_INVALID = 60161
   1735   ,
   1736   /**
   1737    * The provided output buffer is too small.
   1738    */
   1739   MHD_SC_OUT_BUFF_TOO_SMALL = 60180
   1740   ,
   1741   /**
   1742    * The requested type of information is not recognised.
   1743    */
   1744   MHD_SC_INFO_GET_TYPE_UNKNOWN = 60200
   1745   ,
   1746   /**
   1747    * The information of the requested type is too large to fit into
   1748    * the provided buffer.
   1749    */
   1750   MHD_SC_INFO_GET_BUFF_TOO_SMALL = 60201
   1751   ,
   1752   /**
   1753    * The type of the information is not supported by this MHD build.
   1754    * It can be information not supported on the current platform or related
   1755    * to feature disabled for this build.
   1756    */
   1757   MHD_SC_INFO_GET_TYPE_NOT_SUPP_BY_BUILD = 60202
   1758   ,
   1759   /**
   1760    * The type of the information is not available due to configuration
   1761    * or state of the object.
   1762    */
   1763   MHD_SC_INFO_GET_TYPE_NOT_APPLICABLE = 60203
   1764   ,
   1765   /**
   1766    * The type of the information should be available for the object, but
   1767    * cannot be provided due to some error or other reasons.
   1768    */
   1769   MHD_SC_INFO_GET_TYPE_UNOBTAINABLE = 60204
   1770   ,
   1771   /**
   1772    * The type of the Digest Auth algorithm is unknown or not supported.
   1773    */
   1774   MHD_SC_AUTH_DIGEST_ALGO_NOT_SUPPORTED = 60240
   1775   ,
   1776   /**
   1777    * The Digest Auth QOP value is unknown or not supported.
   1778    */
   1779   MHD_SC_AUTH_DIGEST_QOP_NOT_SUPPORTED = 60241
   1780   ,
   1781   /**
   1782    * The Digest Auth is not supported due to configuration
   1783    */
   1784   MHD_SC_AUTH_DIGEST_UNSUPPORTED = 60242
   1785   ,
   1786   /**
   1787    * The application failed to register FD for the external events monitoring
   1788    */
   1789   MHD_SC_EXTR_EVENT_REG_FAILED = 60243
   1790   ,
   1791   /**
   1792    * The application failed to de-register FD for the external events monitoring
   1793    */
   1794   MHD_SC_EXTR_EVENT_DEREG_FAILED = 60244
   1795   ,
   1796   /**
   1797    * The application called #MHD_daemon_event_update() with broken data
   1798    */
   1799   MHD_SC_EXTR_EVENT_BROKEN_DATA = 60250
   1800   ,
   1801   /**
   1802    * The application called #MHD_daemon_event_update() with status that
   1803    * has not been requested
   1804    */
   1805   MHD_SC_EXTR_EVENT_UNEXPECTED_STATUS = 60251
   1806 };
   1807 
   1808 /**
   1809  * Get text description for the MHD error code.
   1810  *
   1811  * This function works for @b MHD error codes, not for @b HTTP status codes.
   1812  * @param code the MHD code to get description for
   1813  * @return the pointer to the text description,
   1814  *         NULL if MHD code in not known.
   1815  *
   1816  * @ingroup general
   1817  */
   1818 MHD_EXTERN_ const struct MHD_String *
   1819 MHD_status_code_to_string (enum MHD_StatusCode code)
   1820 MHD_FN_CONST_;
   1821 
   1822 /**
   1823  * Get the pointer to the C string for the MHD error code, never NULL.
   1824  */
   1825 #define MHD_status_code_to_string_lazy(code) \
   1826         (MHD_status_code_to_string ((code)) ? \
   1827          ((MHD_status_code_to_string (code))->cstr) : ("[No code]") )
   1828 
   1829 #ifndef MHD_HTTP_METHOD_DEFINED
   1830 
   1831 /**
   1832  * @brief HTTP request methods
   1833  *
   1834  * @defgroup methods HTTP methods
   1835  *
   1836  * See: https://www.iana.org/assignments/http-methods/http-methods.xml
   1837  * Registry export date: 2023-10-02
   1838  * @{
   1839  */
   1840 
   1841 /**
   1842  * HTTP methods explicitly supported by MHD.  Note that for non-canonical
   1843  * methods, MHD will return #MHD_HTTP_METHOD_OTHER and you can use
   1844  * #MHD_REQUEST_INFO_FIXED_HTTP_METHOD to get the original string.
   1845  *
   1846  * However, applications must check for #MHD_HTTP_METHOD_OTHER *or* any enum-value
   1847  * above those in this list, as future versions of MHD may add additional
   1848  * methods (as per IANA registry), thus even if the API returns
   1849  * #MHD_HTTP_METHOD_OTHER today, it may return a method-specific header in the
   1850  * future!
   1851  */
   1852 enum MHD_FIXED_ENUM_MHD_SET_ MHD_HTTP_Method
   1853 {
   1854 
   1855   /**
   1856    * Method did not match any of the methods given below.
   1857    */
   1858   MHD_HTTP_METHOD_OTHER = 255
   1859   ,
   1860   /* Main HTTP methods. */
   1861 
   1862   /**
   1863    * "GET"
   1864    * Safe.     Idempotent.     RFC9110, Section 9.3.1.
   1865    */
   1866   MHD_HTTP_METHOD_GET = 1
   1867   ,
   1868   /**
   1869    * "HEAD"
   1870    * Safe.     Idempotent.     RFC9110, Section 9.3.2.
   1871    */
   1872   MHD_HTTP_METHOD_HEAD = 2
   1873   ,
   1874   /**
   1875    * "POST"
   1876    * Not safe. Not idempotent. RFC9110, Section 9.3.3.
   1877    */
   1878   MHD_HTTP_METHOD_POST = 3
   1879   ,
   1880   /**
   1881    * "PUT"
   1882    * Not safe. Idempotent.     RFC9110, Section 9.3.4.
   1883    */
   1884   MHD_HTTP_METHOD_PUT = 4
   1885   ,
   1886   /**
   1887    * "DELETE"
   1888    * Not safe. Idempotent.     RFC9110, Section 9.3.5.
   1889    */
   1890   MHD_HTTP_METHOD_DELETE = 5
   1891   ,
   1892   /**
   1893    * "CONNECT"
   1894    * Not safe. Not idempotent. RFC9110, Section 9.3.6.
   1895    */
   1896   MHD_HTTP_METHOD_CONNECT = 6
   1897   ,
   1898   /**
   1899    * "OPTIONS"
   1900    * Safe.     Idempotent.     RFC9110, Section 9.3.7.
   1901    */
   1902   MHD_HTTP_METHOD_OPTIONS = 7
   1903   ,
   1904   /**
   1905    * "TRACE"
   1906    * Safe.     Idempotent.     RFC9110, Section 9.3.8.
   1907    */
   1908   MHD_HTTP_METHOD_TRACE = 8
   1909   ,
   1910   /**
   1911    * "*"
   1912    * Not safe. Not idempotent. RFC9110, Section 18.2.
   1913    */
   1914   MHD_HTTP_METHOD_ASTERISK = 9
   1915 };
   1916 
   1917 #define MHD_HTTP_METHOD_DEFINED 1
   1918 #endif /* ! MHD_HTTP_METHOD_DEFINED */
   1919 
   1920 /**
   1921  * Get text version of the method name.
   1922  * @param method the method to get the text version
   1923  * @return the pointer to the text version,
   1924  *         NULL if method is MHD_HTTP_METHOD_OTHER
   1925  *         or not known.
   1926  */
   1927 MHD_EXTERN_ const struct MHD_String *
   1928 MHD_http_method_to_string (enum MHD_HTTP_Method method)
   1929 MHD_FN_CONST_;
   1930 
   1931 
   1932 /* Main HTTP methods. */
   1933 /* Safe.     Idempotent.     RFC9110, Section 9.3.1. */
   1934 #define MHD_HTTP_METHOD_STR_GET      "GET"
   1935 /* Safe.     Idempotent.     RFC9110, Section 9.3.2. */
   1936 #define MHD_HTTP_METHOD_STR_HEAD     "HEAD"
   1937 /* Not safe. Not idempotent. RFC9110, Section 9.3.3. */
   1938 #define MHD_HTTP_METHOD_STR_POST     "POST"
   1939 /* Not safe. Idempotent.     RFC9110, Section 9.3.4. */
   1940 #define MHD_HTTP_METHOD_STR_PUT      "PUT"
   1941 /* Not safe. Idempotent.     RFC9110, Section 9.3.5. */
   1942 #define MHD_HTTP_METHOD_STR_DELETE   "DELETE"
   1943 /* Not safe. Not idempotent. RFC9110, Section 9.3.6. */
   1944 #define MHD_HTTP_METHOD_STR_CONNECT  "CONNECT"
   1945 /* Safe.     Idempotent.     RFC9110, Section 9.3.7. */
   1946 #define MHD_HTTP_METHOD_STR_OPTIONS  "OPTIONS"
   1947 /* Safe.     Idempotent.     RFC9110, Section 9.3.8. */
   1948 #define MHD_HTTP_METHOD_STR_TRACE    "TRACE"
   1949 /* Not safe. Not idempotent. RFC9110, Section 18.2. */
   1950 #define MHD_HTTP_METHOD_STR_ASTERISK  "*"
   1951 
   1952 /* Additional HTTP methods. */
   1953 /* Not safe. Idempotent.     RFC3744, Section 8.1. */
   1954 #define MHD_HTTP_METHOD_STR_ACL            "ACL"
   1955 /* Not safe. Idempotent.     RFC3253, Section 12.6. */
   1956 #define MHD_HTTP_METHOD_STR_BASELINE_CONTROL "BASELINE-CONTROL"
   1957 /* Not safe. Idempotent.     RFC5842, Section 4. */
   1958 #define MHD_HTTP_METHOD_STR_BIND           "BIND"
   1959 /* Not safe. Idempotent.     RFC3253, Section 4.4, Section 9.4. */
   1960 #define MHD_HTTP_METHOD_STR_CHECKIN        "CHECKIN"
   1961 /* Not safe. Idempotent.     RFC3253, Section 4.3, Section 8.8. */
   1962 #define MHD_HTTP_METHOD_STR_CHECKOUT       "CHECKOUT"
   1963 /* Not safe. Idempotent.     RFC4918, Section 9.8. */
   1964 #define MHD_HTTP_METHOD_STR_COPY           "COPY"
   1965 /* Not safe. Idempotent.     RFC3253, Section 8.2. */
   1966 #define MHD_HTTP_METHOD_STR_LABEL          "LABEL"
   1967 /* Not safe. Idempotent.     RFC2068, Section 19.6.1.2. */
   1968 #define MHD_HTTP_METHOD_STR_LINK           "LINK"
   1969 /* Not safe. Not idempotent. RFC4918, Section 9.10. */
   1970 #define MHD_HTTP_METHOD_STR_LOCK           "LOCK"
   1971 /* Not safe. Idempotent.     RFC3253, Section 11.2. */
   1972 #define MHD_HTTP_METHOD_STR_MERGE          "MERGE"
   1973 /* Not safe. Idempotent.     RFC3253, Section 13.5. */
   1974 #define MHD_HTTP_METHOD_STR_MKACTIVITY     "MKACTIVITY"
   1975 /* Not safe. Idempotent.     RFC4791, Section 5.3.1; RFC8144, Section 2.3. */
   1976 #define MHD_HTTP_METHOD_STR_MKCALENDAR     "MKCALENDAR"
   1977 /* Not safe. Idempotent.     RFC4918, Section 9.3; RFC5689, Section 3; RFC8144, Section 2.3. */
   1978 #define MHD_HTTP_METHOD_STR_MKCOL          "MKCOL"
   1979 /* Not safe. Idempotent.     RFC4437, Section 6. */
   1980 #define MHD_HTTP_METHOD_STR_MKREDIRECTREF  "MKREDIRECTREF"
   1981 /* Not safe. Idempotent.     RFC3253, Section 6.3. */
   1982 #define MHD_HTTP_METHOD_STR_MKWORKSPACE    "MKWORKSPACE"
   1983 /* Not safe. Idempotent.     RFC4918, Section 9.9. */
   1984 #define MHD_HTTP_METHOD_STR_MOVE           "MOVE"
   1985 /* Not safe. Idempotent.     RFC3648, Section 7. */
   1986 #define MHD_HTTP_METHOD_STR_ORDERPATCH     "ORDERPATCH"
   1987 /* Not safe. Not idempotent. RFC5789, Section 2. */
   1988 #define MHD_HTTP_METHOD_STR_PATCH          "PATCH"
   1989 /* Safe.     Idempotent.     RFC9113, Section 3.4. */
   1990 #define MHD_HTTP_METHOD_STR_PRI            "PRI"
   1991 /* Safe.     Idempotent.     RFC4918, Section 9.1; RFC8144, Section 2.1. */
   1992 #define MHD_HTTP_METHOD_STR_PROPFIND       "PROPFIND"
   1993 /* Not safe. Idempotent.     RFC4918, Section 9.2; RFC8144, Section 2.2. */
   1994 #define MHD_HTTP_METHOD_STR_PROPPATCH      "PROPPATCH"
   1995 /* Not safe. Idempotent.     RFC5842, Section 6. */
   1996 #define MHD_HTTP_METHOD_STR_REBIND         "REBIND"
   1997 /* Safe.     Idempotent.     RFC3253, Section 3.6; RFC8144, Section 2.1. */
   1998 #define MHD_HTTP_METHOD_STR_REPORT         "REPORT"
   1999 /* Safe.     Idempotent.     RFC5323, Section 2. */
   2000 #define MHD_HTTP_METHOD_STR_SEARCH         "SEARCH"
   2001 /* Not safe. Idempotent.     RFC5842, Section 5. */
   2002 #define MHD_HTTP_METHOD_STR_UNBIND         "UNBIND"
   2003 /* Not safe. Idempotent.     RFC3253, Section 4.5. */
   2004 #define MHD_HTTP_METHOD_STR_UNCHECKOUT     "UNCHECKOUT"
   2005 /* Not safe. Idempotent.     RFC2068, Section 19.6.1.3. */
   2006 #define MHD_HTTP_METHOD_STR_UNLINK         "UNLINK"
   2007 /* Not safe. Idempotent.     RFC4918, Section 9.11. */
   2008 #define MHD_HTTP_METHOD_STR_UNLOCK         "UNLOCK"
   2009 /* Not safe. Idempotent.     RFC3253, Section 7.1. */
   2010 #define MHD_HTTP_METHOD_STR_UPDATE         "UPDATE"
   2011 /* Not safe. Idempotent.     RFC4437, Section 7. */
   2012 #define MHD_HTTP_METHOD_STR_UPDATEREDIRECTREF "UPDATEREDIRECTREF"
   2013 /* Not safe. Idempotent.     RFC3253, Section 3.5. */
   2014 #define MHD_HTTP_METHOD_STR_VERSION_CONTROL "VERSION-CONTROL"
   2015 
   2016 /** @} */ /* end of group methods */
   2017 
   2018 #ifndef MHD_HTTP_POSTENCODING_DEFINED
   2019 
   2020 
   2021 /**
   2022  * @brief Possible encodings for HTML forms submitted as HTTP POST requests
   2023  *
   2024  * @defgroup postenc HTTP POST encodings
   2025  * See also: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-2
   2026  * @{
   2027  */
   2028 enum MHD_FIXED_ENUM_MHD_APP_SET_ MHD_HTTP_PostEncoding
   2029 {
   2030   /**
   2031    * No post encoding / broken data / unknown encoding
   2032    */
   2033   MHD_HTTP_POST_ENCODING_OTHER = 0
   2034   ,
   2035   /**
   2036    * "application/x-www-form-urlencoded"
   2037    * See https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#url-encoded-form-data
   2038    * See https://url.spec.whatwg.org/#application/x-www-form-urlencoded
   2039    * See https://datatracker.ietf.org/doc/html/rfc3986#section-2
   2040    */
   2041   MHD_HTTP_POST_ENCODING_FORM_URLENCODED = 1
   2042   ,
   2043   /**
   2044    * "multipart/form-data"
   2045    * See https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data
   2046    * See https://www.rfc-editor.org/rfc/rfc7578.html
   2047    */
   2048   MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA = 2
   2049   ,
   2050   /**
   2051    * "text/plain"
   2052    * Introduced by HTML5
   2053    * See https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data
   2054    * @warning Format is ambiguous. Do not use unless there is a very strong reason.
   2055    */
   2056   MHD_HTTP_POST_ENCODING_TEXT_PLAIN = 3
   2057 };
   2058 
   2059 
   2060 /** @} */ /* end of group postenc */
   2061 
   2062 #define MHD_HTTP_POSTENCODING_DEFINED 1
   2063 #endif /* ! MHD_HTTP_POSTENCODING_DEFINED */
   2064 
   2065 
   2066 /**
   2067  * @brief Standard headers found in HTTP requests and responses.
   2068  *
   2069  * See: https://www.iana.org/assignments/http-fields/http-fields.xhtml
   2070  *
   2071  * @defgroup headers HTTP headers
   2072  * Registry export date: 2023-10-02
   2073  * @{
   2074  */
   2075 
   2076 /* Main HTTP headers. */
   2077 /* Permanent.     RFC9110, Section 12.5.1: HTTP Semantics */
   2078 #define MHD_HTTP_HEADER_ACCEPT       "Accept"
   2079 /* Deprecated.    RFC9110, Section 12.5.2: HTTP Semantics */
   2080 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
   2081 /* Permanent.     RFC9110, Section 12.5.3: HTTP Semantics */
   2082 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
   2083 /* Permanent.     RFC9110, Section 12.5.4: HTTP Semantics */
   2084 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
   2085 /* Permanent.     RFC9110, Section 14.3: HTTP Semantics */
   2086 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
   2087 /* Permanent.     RFC9111, Section 5.1: HTTP Caching */
   2088 #define MHD_HTTP_HEADER_AGE          "Age"
   2089 /* Permanent.     RFC9110, Section 10.2.1: HTTP Semantics */
   2090 #define MHD_HTTP_HEADER_ALLOW        "Allow"
   2091 /* Permanent.     RFC9110, Section 11.6.3: HTTP Semantics */
   2092 #define MHD_HTTP_HEADER_AUTHENTICATION_INFO "Authentication-Info"
   2093 /* Permanent.     RFC9110, Section 11.6.2: HTTP Semantics */
   2094 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
   2095 /* Permanent.     RFC9111, Section 5.2 */
   2096 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
   2097 /* Permanent.     RFC9112, Section 9.6: HTTP/1.1 */
   2098 #define MHD_HTTP_HEADER_CLOSE        "Close"
   2099 /* Permanent.     RFC9110, Section 7.6.1: HTTP Semantics */
   2100 #define MHD_HTTP_HEADER_CONNECTION   "Connection"
   2101 /* Permanent.     RFC9110, Section 8.4: HTTP Semantics */
   2102 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
   2103 /* Permanent.     RFC9110, Section 8.5: HTTP Semantics */
   2104 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
   2105 /* Permanent.     RFC9110, Section 8.6: HTTP Semantics */
   2106 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
   2107 /* Permanent.     RFC9110, Section 8.7: HTTP Semantics */
   2108 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
   2109 /* Permanent.     RFC9110, Section 14.4: HTTP Semantics */
   2110 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
   2111 /* Permanent.     RFC9110, Section 8.3: HTTP Semantics */
   2112 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
   2113 /* Permanent.     RFC9110, Section 6.6.1: HTTP Semantics */
   2114 #define MHD_HTTP_HEADER_DATE         "Date"
   2115 /* Permanent.     RFC9110, Section 8.8.3: HTTP Semantics */
   2116 #define MHD_HTTP_HEADER_ETAG         "ETag"
   2117 /* Permanent.     RFC9110, Section 10.1.1: HTTP Semantics */
   2118 #define MHD_HTTP_HEADER_EXPECT       "Expect"
   2119 /* Permanent.     RFC9111, Section 5.3: HTTP Caching */
   2120 #define MHD_HTTP_HEADER_EXPIRES      "Expires"
   2121 /* Permanent.     RFC9110, Section 10.1.2: HTTP Semantics */
   2122 #define MHD_HTTP_HEADER_FROM         "From"
   2123 /* Permanent.     RFC9110, Section 7.2: HTTP Semantics */
   2124 #define MHD_HTTP_HEADER_HOST         "Host"
   2125 /* Permanent.     RFC9110, Section 13.1.1: HTTP Semantics */
   2126 #define MHD_HTTP_HEADER_IF_MATCH     "If-Match"
   2127 /* Permanent.     RFC9110, Section 13.1.3: HTTP Semantics */
   2128 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
   2129 /* Permanent.     RFC9110, Section 13.1.2: HTTP Semantics */
   2130 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
   2131 /* Permanent.     RFC9110, Section 13.1.5: HTTP Semantics */
   2132 #define MHD_HTTP_HEADER_IF_RANGE     "If-Range"
   2133 /* Permanent.     RFC9110, Section 13.1.4: HTTP Semantics */
   2134 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
   2135 /* Permanent.     RFC9110, Section 8.8.2: HTTP Semantics */
   2136 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
   2137 /* Permanent.     RFC9110, Section 10.2.2: HTTP Semantics */
   2138 #define MHD_HTTP_HEADER_LOCATION     "Location"
   2139 /* Permanent.     RFC9110, Section 7.6.2: HTTP Semantics */
   2140 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
   2141 /* Permanent.     RFC9112, Appendix B.1: HTTP/1.1 */
   2142 #define MHD_HTTP_HEADER_MIME_VERSION "MIME-Version"
   2143 /* Deprecated.    RFC9111, Section 5.4: HTTP Caching */
   2144 #define MHD_HTTP_HEADER_PRAGMA       "Pragma"
   2145 /* Permanent.     RFC9110, Section 11.7.1: HTTP Semantics */
   2146 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
   2147 /* Permanent.     RFC9110, Section 11.7.3: HTTP Semantics */
   2148 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATION_INFO "Proxy-Authentication-Info"
   2149 /* Permanent.     RFC9110, Section 11.7.2: HTTP Semantics */
   2150 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
   2151 /* Permanent.     RFC9110, Section 14.2: HTTP Semantics */
   2152 #define MHD_HTTP_HEADER_RANGE        "Range"
   2153 /* Permanent.     RFC9110, Section 10.1.3: HTTP Semantics */
   2154 #define MHD_HTTP_HEADER_REFERER      "Referer"
   2155 /* Permanent.     RFC9110, Section 10.2.3: HTTP Semantics */
   2156 #define MHD_HTTP_HEADER_RETRY_AFTER  "Retry-After"
   2157 /* Permanent.     RFC9110, Section 10.2.4: HTTP Semantics */
   2158 #define MHD_HTTP_HEADER_SERVER       "Server"
   2159 /* Permanent.     RFC9110, Section 10.1.4: HTTP Semantics */
   2160 #define MHD_HTTP_HEADER_TE           "TE"
   2161 /* Permanent.     RFC9110, Section 6.6.2: HTTP Semantics */
   2162 #define MHD_HTTP_HEADER_TRAILER      "Trailer"
   2163 /* Permanent.     RFC9112, Section 6.1: HTTP Semantics */
   2164 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
   2165 /* Permanent.     RFC9110, Section 7.8: HTTP Semantics */
   2166 #define MHD_HTTP_HEADER_UPGRADE      "Upgrade"
   2167 /* Permanent.     RFC9110, Section 10.1.5: HTTP Semantics */
   2168 #define MHD_HTTP_HEADER_USER_AGENT   "User-Agent"
   2169 /* Permanent.     RFC9110, Section 12.5.5: HTTP Semantics */
   2170 #define MHD_HTTP_HEADER_VARY         "Vary"
   2171 /* Permanent.     RFC9110, Section 7.6.3: HTTP Semantics */
   2172 #define MHD_HTTP_HEADER_VIA          "Via"
   2173 /* Permanent.     RFC9110, Section 11.6.1: HTTP Semantics */
   2174 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
   2175 /* Permanent.     RFC9110, Section 12.5.5: HTTP Semantics */
   2176 #define MHD_HTTP_HEADER_ASTERISK     "*"
   2177 
   2178 /* Additional HTTP headers. */
   2179 /* Permanent.     RFC 3229: Delta encoding in HTTP */
   2180 #define MHD_HTTP_HEADER_A_IM         "A-IM"
   2181 /* Permanent.     RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) */
   2182 #define MHD_HTTP_HEADER_ACCEPT_ADDITIONS "Accept-Additions"
   2183 /* Permanent.     RFC 8942, Section 3.1: HTTP Client Hints */
   2184 #define MHD_HTTP_HEADER_ACCEPT_CH    "Accept-CH"
   2185 /* Permanent.     RFC 7089: HTTP Framework for Time-Based Access to Resource States -- Memento */
   2186 #define MHD_HTTP_HEADER_ACCEPT_DATETIME "Accept-Datetime"
   2187 /* Permanent.     RFC 2295: Transparent Content Negotiation in HTTP */
   2188 #define MHD_HTTP_HEADER_ACCEPT_FEATURES "Accept-Features"
   2189 /* Permanent.     RFC 5789: PATCH Method for HTTP */
   2190 #define MHD_HTTP_HEADER_ACCEPT_PATCH "Accept-Patch"
   2191 /* Permanent.     Linked Data Platform 1.0 */
   2192 #define MHD_HTTP_HEADER_ACCEPT_POST  "Accept-Post"
   2193 /* Permanent.     RFC-ietf-httpbis-message-signatures-19, Section 5.1: HTTP Message Signatures */
   2194 #define MHD_HTTP_HEADER_ACCEPT_SIGNATURE "Accept-Signature"
   2195 /* Permanent.     Fetch */
   2196 #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS \
   2197         "Access-Control-Allow-Credentials"
   2198 /* Permanent.     Fetch */
   2199 #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_HEADERS \
   2200         "Access-Control-Allow-Headers"
   2201 /* Permanent.     Fetch */
   2202 #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_METHODS \
   2203         "Access-Control-Allow-Methods"
   2204 /* Permanent.     Fetch */
   2205 #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN \
   2206         "Access-Control-Allow-Origin"
   2207 /* Permanent.     Fetch */
   2208 #define MHD_HTTP_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS \
   2209         "Access-Control-Expose-Headers"
   2210 /* Permanent.     Fetch */
   2211 #define MHD_HTTP_HEADER_ACCESS_CONTROL_MAX_AGE "Access-Control-Max-Age"
   2212 /* Permanent.     Fetch */
   2213 #define MHD_HTTP_HEADER_ACCESS_CONTROL_REQUEST_HEADERS \
   2214         "Access-Control-Request-Headers"
   2215 /* Permanent.     Fetch */
   2216 #define MHD_HTTP_HEADER_ACCESS_CONTROL_REQUEST_METHOD \
   2217         "Access-Control-Request-Method"
   2218 /* Permanent.     RFC 7639, Section 2: The ALPN HTTP Header Field */
   2219 #define MHD_HTTP_HEADER_ALPN         "ALPN"
   2220 /* Permanent.     RFC 7838: HTTP Alternative Services */
   2221 #define MHD_HTTP_HEADER_ALT_SVC      "Alt-Svc"
   2222 /* Permanent.     RFC 7838: HTTP Alternative Services */
   2223 #define MHD_HTTP_HEADER_ALT_USED     "Alt-Used"
   2224 /* Permanent.     RFC 2295: Transparent Content Negotiation in HTTP */
   2225 #define MHD_HTTP_HEADER_ALTERNATES   "Alternates"
   2226 /* Permanent.     RFC 4437: Web Distributed Authoring and Versioning (WebDAV) Redirect Reference Resources */
   2227 #define MHD_HTTP_HEADER_APPLY_TO_REDIRECT_REF "Apply-To-Redirect-Ref"
   2228 /* Permanent.     RFC 8053, Section 4: HTTP Authentication Extensions for Interactive Clients */
   2229 #define MHD_HTTP_HEADER_AUTHENTICATION_CONTROL "Authentication-Control"
   2230 /* Permanent.     RFC9211: The Cache-Status HTTP Response Header Field */
   2231 #define MHD_HTTP_HEADER_CACHE_STATUS "Cache-Status"
   2232 /* Permanent.     RFC 8607, Section 5.1: Calendaring Extensions to WebDAV (CalDAV): Managed Attachments */
   2233 #define MHD_HTTP_HEADER_CAL_MANAGED_ID "Cal-Managed-ID"
   2234 /* Permanent.     RFC 7809, Section 7.1: Calendaring Extensions to WebDAV (CalDAV): Time Zones by Reference */
   2235 #define MHD_HTTP_HEADER_CALDAV_TIMEZONES "CalDAV-Timezones"
   2236 /* Permanent.     RFC9297 */
   2237 #define MHD_HTTP_HEADER_CAPSULE_PROTOCOL "Capsule-Protocol"
   2238 /* Permanent.     RFC9213: Targeted HTTP Cache Control */
   2239 #define MHD_HTTP_HEADER_CDN_CACHE_CONTROL "CDN-Cache-Control"
   2240 /* Permanent.     RFC 8586: Loop Detection in Content Delivery Networks (CDNs) */
   2241 #define MHD_HTTP_HEADER_CDN_LOOP     "CDN-Loop"
   2242 /* Permanent.     RFC 8739, Section 3.3: Support for Short-Term, Automatically Renewed (STAR) Certificates in the Automated Certificate Management Environment (ACME) */
   2243 #define MHD_HTTP_HEADER_CERT_NOT_AFTER "Cert-Not-After"
   2244 /* Permanent.     RFC 8739, Section 3.3: Support for Short-Term, Automatically Renewed (STAR) Certificates in the Automated Certificate Management Environment (ACME) */
   2245 #define MHD_HTTP_HEADER_CERT_NOT_BEFORE "Cert-Not-Before"
   2246 /* Permanent.     Clear Site Data */
   2247 #define MHD_HTTP_HEADER_CLEAR_SITE_DATA "Clear-Site-Data"
   2248 /* Permanent.     RFC9440, Section 2: Client-Cert HTTP Header Field */
   2249 #define MHD_HTTP_HEADER_CLIENT_CERT  "Client-Cert"
   2250 /* Permanent.     RFC9440, Section 2: Client-Cert HTTP Header Field */
   2251 #define MHD_HTTP_HEADER_CLIENT_CERT_CHAIN "Client-Cert-Chain"
   2252 /* Permanent.     RFC-ietf-httpbis-digest-headers-13, Section 2: Digest Fields */
   2253 #define MHD_HTTP_HEADER_CONTENT_DIGEST "Content-Digest"
   2254 /* Permanent.     RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP) */
   2255 #define MHD_HTTP_HEADER_CONTENT_DISPOSITION "Content-Disposition"
   2256 /* Permanent.     The HTTP Distribution and Replication Protocol */
   2257 #define MHD_HTTP_HEADER_CONTENT_ID   "Content-ID"
   2258 /* Permanent.     Content Security Policy Level 3 */
   2259 #define MHD_HTTP_HEADER_CONTENT_SECURITY_POLICY "Content-Security-Policy"
   2260 /* Permanent.     Content Security Policy Level 3 */
   2261 #define MHD_HTTP_HEADER_CONTENT_SECURITY_POLICY_REPORT_ONLY \
   2262         "Content-Security-Policy-Report-Only"
   2263 /* Permanent.     RFC 6265: HTTP State Management Mechanism */
   2264 #define MHD_HTTP_HEADER_COOKIE       "Cookie"
   2265 /* Permanent.     HTML */
   2266 #define MHD_HTTP_HEADER_CROSS_ORIGIN_EMBEDDER_POLICY \
   2267         "Cross-Origin-Embedder-Policy"
   2268 /* Permanent.     HTML */
   2269 #define MHD_HTTP_HEADER_CROSS_ORIGIN_EMBEDDER_POLICY_REPORT_ONLY \
   2270         "Cross-Origin-Embedder-Policy-Report-Only"
   2271 /* Permanent.     HTML */
   2272 #define MHD_HTTP_HEADER_CROSS_ORIGIN_OPENER_POLICY "Cross-Origin-Opener-Policy"
   2273 /* Permanent.     HTML */
   2274 #define MHD_HTTP_HEADER_CROSS_ORIGIN_OPENER_POLICY_REPORT_ONLY \
   2275         "Cross-Origin-Opener-Policy-Report-Only"
   2276 /* Permanent.     Fetch */
   2277 #define MHD_HTTP_HEADER_CROSS_ORIGIN_RESOURCE_POLICY \
   2278         "Cross-Origin-Resource-Policy"
   2279 /* Permanent.     RFC 5323: Web Distributed Authoring and Versioning (WebDAV) SEARCH */
   2280 #define MHD_HTTP_HEADER_DASL         "DASL"
   2281 /* Permanent.     RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */
   2282 #define MHD_HTTP_HEADER_DAV          "DAV"
   2283 /* Permanent.     RFC 3229: Delta encoding in HTTP */
   2284 #define MHD_HTTP_HEADER_DELTA_BASE   "Delta-Base"
   2285 /* Permanent.     RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */
   2286 #define MHD_HTTP_HEADER_DEPTH        "Depth"
   2287 /* Permanent.     RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */
   2288 #define MHD_HTTP_HEADER_DESTINATION  "Destination"
   2289 /* Permanent.     The HTTP Distribution and Replication Protocol */
   2290 #define MHD_HTTP_HEADER_DIFFERENTIAL_ID "Differential-ID"
   2291 /* Permanent.     RFC9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP) */
   2292 #define MHD_HTTP_HEADER_DPOP         "DPoP"
   2293 /* Permanent.     RFC9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP) */
   2294 #define MHD_HTTP_HEADER_DPOP_NONCE   "DPoP-Nonce"
   2295 /* Permanent.     RFC 8470: Using Early Data in HTTP */
   2296 #define MHD_HTTP_HEADER_EARLY_DATA   "Early-Data"
   2297 /* Permanent.     RFC9163: Expect-CT Extension for HTTP */
   2298 #define MHD_HTTP_HEADER_EXPECT_CT    "Expect-CT"
   2299 /* Permanent.     RFC 7239: Forwarded HTTP Extension */
   2300 #define MHD_HTTP_HEADER_FORWARDED    "Forwarded"
   2301 /* Permanent.     RFC 7486, Section 6.1.1: HTTP Origin-Bound Authentication (HOBA) */
   2302 #define MHD_HTTP_HEADER_HOBAREG      "Hobareg"
   2303 /* Permanent.     RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */
   2304 #define MHD_HTTP_HEADER_IF           "If"
   2305 /* Permanent.      RFC 6338: Scheduling Extensions to CalDAV */
   2306 #define MHD_HTTP_HEADER_IF_SCHEDULE_TAG_MATCH "If-Schedule-Tag-Match"
   2307 /* Permanent.     RFC 3229: Delta encoding in HTTP */
   2308 #define MHD_HTTP_HEADER_IM           "IM"
   2309 /* Permanent.     RFC 8473: Token Binding over HTTP */
   2310 #define MHD_HTTP_HEADER_INCLUDE_REFERRED_TOKEN_BINDING_ID \
   2311         "Include-Referred-Token-Binding-ID"
   2312 /* Permanent.     RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */
   2313 #define MHD_HTTP_HEADER_KEEP_ALIVE   "Keep-Alive"
   2314 /* Permanent.     RFC 3253: Versioning Extensions to WebDAV: (Web Distributed Authoring and Versioning) */
   2315 #define MHD_HTTP_HEADER_LABEL        "Label"
   2316 /* Permanent.     HTML */
   2317 #define MHD_HTTP_HEADER_LAST_EVENT_ID "Last-Event-ID"
   2318 /* Permanent.     RFC 8288: Web Linking */
   2319 #define MHD_HTTP_HEADER_LINK         "Link"
   2320 /* Permanent.     RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */
   2321 #define MHD_HTTP_HEADER_LOCK_TOKEN   "Lock-Token"
   2322 /* Permanent.     RFC 7089: HTTP Framework for Time-Based Access to Resource States -- Memento */
   2323 #define MHD_HTTP_HEADER_MEMENTO_DATETIME "Memento-Datetime"
   2324 /* Permanent.     RFC 2227: Simple Hit-Metering and Usage-Limiting for HTTP */
   2325 #define MHD_HTTP_HEADER_METER        "Meter"
   2326 /* Permanent.     RFC 2295: Transparent Content Negotiation in HTTP */
   2327 #define MHD_HTTP_HEADER_NEGOTIATE    "Negotiate"
   2328 /* Permanent.     Network Error Logging */
   2329 #define MHD_HTTP_HEADER_NEL          "NEL"
   2330 /* Permanent.     OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */
   2331 #define MHD_HTTP_HEADER_ODATA_ENTITYID "OData-EntityId"
   2332 /* Permanent.     OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */
   2333 #define MHD_HTTP_HEADER_ODATA_ISOLATION "OData-Isolation"
   2334 /* Permanent.     OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */
   2335 #define MHD_HTTP_HEADER_ODATA_MAXVERSION "OData-MaxVersion"
   2336 /* Permanent.     OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */
   2337 #define MHD_HTTP_HEADER_ODATA_VERSION "OData-Version"
   2338 /* Permanent.     RFC 8053, Section 3: HTTP Authentication Extensions for Interactive Clients */
   2339 #define MHD_HTTP_HEADER_OPTIONAL_WWW_AUTHENTICATE "Optional-WWW-Authenticate"
   2340 /* Permanent.     RFC 3648: Web Distributed Authoring and Versioning (WebDAV) Ordered Collections Protocol */
   2341 #define MHD_HTTP_HEADER_ORDERING_TYPE "Ordering-Type"
   2342 /* Permanent.     RFC 6454: The Web Origin Concept */
   2343 #define MHD_HTTP_HEADER_ORIGIN       "Origin"
   2344 /* Permanent.     HTML */
   2345 #define MHD_HTTP_HEADER_ORIGIN_AGENT_CLUSTER "Origin-Agent-Cluster"
   2346 /* Permanent.     RFC 8613, Section 11.1: Object Security for Constrained RESTful Environments (OSCORE) */
   2347 #define MHD_HTTP_HEADER_OSCORE       "OSCORE"
   2348 /* Permanent.     OASIS Project Specification 01; OASIS; Chet_Ensign */
   2349 #define MHD_HTTP_HEADER_OSLC_CORE_VERSION "OSLC-Core-Version"
   2350 /* Permanent.     RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */
   2351 #define MHD_HTTP_HEADER_OVERWRITE    "Overwrite"
   2352 /* Permanent.     HTML */
   2353 #define MHD_HTTP_HEADER_PING_FROM    "Ping-From"
   2354 /* Permanent.     HTML */
   2355 #define MHD_HTTP_HEADER_PING_TO      "Ping-To"
   2356 /* Permanent.     RFC 3648: Web Distributed Authoring and Versioning (WebDAV) Ordered Collections Protocol */
   2357 #define MHD_HTTP_HEADER_POSITION     "Position"
   2358 /* Permanent.     RFC 7240: Prefer Header for HTTP */
   2359 #define MHD_HTTP_HEADER_PREFER       "Prefer"
   2360 /* Permanent.     RFC 7240: Prefer Header for HTTP */
   2361 #define MHD_HTTP_HEADER_PREFERENCE_APPLIED "Preference-Applied"
   2362 /* Permanent.     RFC9218: Extensible Prioritization Scheme for HTTP */
   2363 #define MHD_HTTP_HEADER_PRIORITY     "Priority"
   2364 /* Permanent.     RFC9209: The Proxy-Status HTTP Response Header Field */
   2365 #define MHD_HTTP_HEADER_PROXY_STATUS "Proxy-Status"
   2366 /* Permanent.     RFC 7469: Public Key Pinning Extension for HTTP */
   2367 #define MHD_HTTP_HEADER_PUBLIC_KEY_PINS "Public-Key-Pins"
   2368 /* Permanent.     RFC 7469: Public Key Pinning Extension for HTTP */
   2369 #define MHD_HTTP_HEADER_PUBLIC_KEY_PINS_REPORT_ONLY \
   2370         "Public-Key-Pins-Report-Only"
   2371 /* Permanent.     RFC 4437: Web Distributed Authoring and Versioning (WebDAV) Redirect Reference Resources */
   2372 #define MHD_HTTP_HEADER_REDIRECT_REF "Redirect-Ref"
   2373 /* Permanent.     HTML */
   2374 #define MHD_HTTP_HEADER_REFRESH      "Refresh"
   2375 /* Permanent.     RFC 8555, Section 6.5.1: Automatic Certificate Management Environment (ACME) */
   2376 #define MHD_HTTP_HEADER_REPLAY_NONCE "Replay-Nonce"
   2377 /* Permanent.     RFC-ietf-httpbis-digest-headers-13, Section 3: Digest Fields */
   2378 #define MHD_HTTP_HEADER_REPR_DIGEST  "Repr-Digest"
   2379 /* Permanent.     RFC 6638: Scheduling Extensions to CalDAV */
   2380 #define MHD_HTTP_HEADER_SCHEDULE_REPLY "Schedule-Reply"
   2381 /* Permanent.     RFC 6338: Scheduling Extensions to CalDAV */
   2382 #define MHD_HTTP_HEADER_SCHEDULE_TAG "Schedule-Tag"
   2383 /* Permanent.     Fetch */
   2384 #define MHD_HTTP_HEADER_SEC_PURPOSE  "Sec-Purpose"
   2385 /* Permanent.     RFC 8473: Token Binding over HTTP */
   2386 #define MHD_HTTP_HEADER_SEC_TOKEN_BINDING "Sec-Token-Binding"
   2387 /* Permanent.     RFC 6455: The WebSocket Protocol */
   2388 #define MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT "Sec-WebSocket-Accept"
   2389 /* Permanent.     RFC 6455: The WebSocket Protocol */
   2390 #define MHD_HTTP_HEADER_SEC_WEBSOCKET_EXTENSIONS "Sec-WebSocket-Extensions"
   2391 /* Permanent.     RFC 6455: The WebSocket Protocol */
   2392 #define MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY "Sec-WebSocket-Key"
   2393 /* Permanent.     RFC 6455: The WebSocket Protocol */
   2394 #define MHD_HTTP_HEADER_SEC_WEBSOCKET_PROTOCOL "Sec-WebSocket-Protocol"
   2395 /* Permanent.     RFC 6455: The WebSocket Protocol */
   2396 #define MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION "Sec-WebSocket-Version"
   2397 /* Permanent.     Server Timing */
   2398 #define MHD_HTTP_HEADER_SERVER_TIMING "Server-Timing"
   2399 /* Permanent.     RFC 6265: HTTP State Management Mechanism */
   2400 #define MHD_HTTP_HEADER_SET_COOKIE   "Set-Cookie"
   2401 /* Permanent.     RFC-ietf-httpbis-message-signatures-19, Section 4.2: HTTP Message Signatures */
   2402 #define MHD_HTTP_HEADER_SIGNATURE    "Signature"
   2403 /* Permanent.     RFC-ietf-httpbis-message-signatures-19, Section 4.1: HTTP Message Signatures */
   2404 #define MHD_HTTP_HEADER_SIGNATURE_INPUT "Signature-Input"
   2405 /* Permanent.     RFC 5023: The Atom Publishing Protocol */
   2406 #define MHD_HTTP_HEADER_SLUG         "SLUG"
   2407 /* Permanent.     Simple Object Access Protocol (SOAP) 1.1 */
   2408 #define MHD_HTTP_HEADER_SOAPACTION   "SoapAction"
   2409 /* Permanent.     RFC 2518: HTTP Extensions for Distributed Authoring -- WEBDAV */
   2410 #define MHD_HTTP_HEADER_STATUS_URI   "Status-URI"
   2411 /* Permanent.     RFC 6797: HTTP Strict Transport Security (HSTS) */
   2412 #define MHD_HTTP_HEADER_STRICT_TRANSPORT_SECURITY "Strict-Transport-Security"
   2413 /* Permanent.     RFC 8594: The Sunset HTTP Header Field */
   2414 #define MHD_HTTP_HEADER_SUNSET       "Sunset"
   2415 /* Permanent.     Edge Architecture Specification */
   2416 #define MHD_HTTP_HEADER_SURROGATE_CAPABILITY "Surrogate-Capability"
   2417 /* Permanent.     Edge Architecture Specification */
   2418 #define MHD_HTTP_HEADER_SURROGATE_CONTROL "Surrogate-Control"
   2419 /* Permanent.     RFC 2295: Transparent Content Negotiation in HTTP */
   2420 #define MHD_HTTP_HEADER_TCN          "TCN"
   2421 /* Permanent.     RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */
   2422 #define MHD_HTTP_HEADER_TIMEOUT      "Timeout"
   2423 /* Permanent.     RFC 8030, Section 5.4: Generic Event Delivery Using HTTP Push */
   2424 #define MHD_HTTP_HEADER_TOPIC        "Topic"
   2425 /* Permanent.     Trace Context */
   2426 #define MHD_HTTP_HEADER_TRACEPARENT  "Traceparent"
   2427 /* Permanent.     Trace Context */
   2428 #define MHD_HTTP_HEADER_TRACESTATE   "Tracestate"
   2429 /* Permanent.     RFC 8030, Section 5.2: Generic Event Delivery Using HTTP Push */
   2430 #define MHD_HTTP_HEADER_TTL          "TTL"
   2431 /* Permanent.     RFC 8030, Section 5.3: Generic Event Delivery Using HTTP Push */
   2432 #define MHD_HTTP_HEADER_URGENCY      "Urgency"
   2433 /* Permanent.     RFC 2295: Transparent Content Negotiation in HTTP */
   2434 #define MHD_HTTP_HEADER_VARIANT_VARY "Variant-Vary"
   2435 /* Permanent.     RFC-ietf-httpbis-digest-headers-13, Section 4: Digest Fields */
   2436 #define MHD_HTTP_HEADER_WANT_CONTENT_DIGEST "Want-Content-Digest"
   2437 /* Permanent.     RFC-ietf-httpbis-digest-headers-13, Section 4: Digest Fields */
   2438 #define MHD_HTTP_HEADER_WANT_REPR_DIGEST "Want-Repr-Digest"
   2439 /* Permanent.     Fetch */
   2440 #define MHD_HTTP_HEADER_X_CONTENT_TYPE_OPTIONS "X-Content-Type-Options"
   2441 /* Permanent.     HTML */
   2442 #define MHD_HTTP_HEADER_X_FRAME_OPTIONS "X-Frame-Options"
   2443 /* Provisional.   AMP-Cache-Transform HTTP request header */
   2444 #define MHD_HTTP_HEADER_AMP_CACHE_TRANSFORM "AMP-Cache-Transform"
   2445 /* Provisional.   OSLC Configuration Management Version 1.0. Part 3: Configuration Specification */
   2446 #define MHD_HTTP_HEADER_CONFIGURATION_CONTEXT "Configuration-Context"
   2447 /* Provisional.   RFC 6017: Electronic Data Interchange - Internet Integration (EDIINT) Features Header Field */
   2448 #define MHD_HTTP_HEADER_EDIINT_FEATURES "EDIINT-Features"
   2449 /* Provisional.   OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */
   2450 #define MHD_HTTP_HEADER_ISOLATION    "Isolation"
   2451 /* Provisional.   Permissions Policy */
   2452 #define MHD_HTTP_HEADER_PERMISSIONS_POLICY "Permissions-Policy"
   2453 /* Provisional.   Repeatable Requests Version 1.0; OASIS; Chet_Ensign */
   2454 #define MHD_HTTP_HEADER_REPEATABILITY_CLIENT_ID "Repeatability-Client-ID"
   2455 /* Provisional.   Repeatable Requests Version 1.0; OASIS; Chet_Ensign */
   2456 #define MHD_HTTP_HEADER_REPEATABILITY_FIRST_SENT "Repeatability-First-Sent"
   2457 /* Provisional.   Repeatable Requests Version 1.0; OASIS; Chet_Ensign */
   2458 #define MHD_HTTP_HEADER_REPEATABILITY_REQUEST_ID "Repeatability-Request-ID"
   2459 /* Provisional.   Repeatable Requests Version 1.0; OASIS; Chet_Ensign */
   2460 #define MHD_HTTP_HEADER_REPEATABILITY_RESULT "Repeatability-Result"
   2461 /* Provisional.   Reporting API */
   2462 #define MHD_HTTP_HEADER_REPORTING_ENDPOINTS "Reporting-Endpoints"
   2463 /* Provisional.   Global Privacy Control (GPC) */
   2464 #define MHD_HTTP_HEADER_SEC_GPC      "Sec-GPC"
   2465 /* Provisional.   Resource Timing Level 1 */
   2466 #define MHD_HTTP_HEADER_TIMING_ALLOW_ORIGIN "Timing-Allow-Origin"
   2467 /* Deprecated.    PEP - an Extension Mechanism for HTTP; status-change-http-experiments-to-historic */
   2468 #define MHD_HTTP_HEADER_C_PEP_INFO   "C-PEP-Info"
   2469 /* Deprecated.    White Paper: Joint Electronic Payment Initiative */
   2470 #define MHD_HTTP_HEADER_PROTOCOL_INFO "Protocol-Info"
   2471 /* Deprecated.    White Paper: Joint Electronic Payment Initiative */
   2472 #define MHD_HTTP_HEADER_PROTOCOL_QUERY "Protocol-Query"
   2473 /* Obsoleted.     Access Control for Cross-site Requests */
   2474 #define MHD_HTTP_HEADER_ACCESS_CONTROL "Access-Control"
   2475 /* Obsoleted.     RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */
   2476 #define MHD_HTTP_HEADER_C_EXT        "C-Ext"
   2477 /* Obsoleted.     RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */
   2478 #define MHD_HTTP_HEADER_C_MAN        "C-Man"
   2479 /* Obsoleted.     RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */
   2480 #define MHD_HTTP_HEADER_C_OPT        "C-Opt"
   2481 /* Obsoleted.     PEP - an Extension Mechanism for HTTP; status-change-http-experiments-to-historic */
   2482 #define MHD_HTTP_HEADER_C_PEP        "C-PEP"
   2483 /* Obsoleted.     RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1; RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 */
   2484 #define MHD_HTTP_HEADER_CONTENT_BASE "Content-Base"
   2485 /* Obsoleted.     RFC 2616, Section 14.15: Hypertext Transfer Protocol -- HTTP/1.1; RFC 7231, Appendix B: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content */
   2486 #define MHD_HTTP_HEADER_CONTENT_MD5  "Content-MD5"
   2487 /* Obsoleted.     HTML 4.01 Specification */
   2488 #define MHD_HTTP_HEADER_CONTENT_SCRIPT_TYPE "Content-Script-Type"
   2489 /* Obsoleted.     HTML 4.01 Specification */
   2490 #define MHD_HTTP_HEADER_CONTENT_STYLE_TYPE "Content-Style-Type"
   2491 /* Obsoleted.     RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */
   2492 #define MHD_HTTP_HEADER_CONTENT_VERSION "Content-Version"
   2493 /* Obsoleted.     RFC 2965: HTTP State Management Mechanism; RFC 6265: HTTP State Management Mechanism */
   2494 #define MHD_HTTP_HEADER_COOKIE2      "Cookie2"
   2495 /* Obsoleted.     HTML 4.01 Specification */
   2496 #define MHD_HTTP_HEADER_DEFAULT_STYLE "Default-Style"
   2497 /* Obsoleted.     RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */
   2498 #define MHD_HTTP_HEADER_DERIVED_FROM "Derived-From"
   2499 /* Obsoleted.     RFC 3230: Instance Digests in HTTP; RFC-ietf-httpbis-digest-headers-13, Section 1.3: Digest Fields */
   2500 #define MHD_HTTP_HEADER_DIGEST       "Digest"
   2501 /* Obsoleted.     RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */
   2502 #define MHD_HTTP_HEADER_EXT          "Ext"
   2503 /* Obsoleted.     Implementation of OPS Over HTTP */
   2504 #define MHD_HTTP_HEADER_GETPROFILE   "GetProfile"
   2505 /* Obsoleted.     RFC 7540, Section 3.2.1: Hypertext Transfer Protocol Version 2 (HTTP/2) */
   2506 #define MHD_HTTP_HEADER_HTTP2_SETTINGS "HTTP2-Settings"
   2507 /* Obsoleted.     RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */
   2508 #define MHD_HTTP_HEADER_MAN          "Man"
   2509 /* Obsoleted.     Access Control for Cross-site Requests */
   2510 #define MHD_HTTP_HEADER_METHOD_CHECK "Method-Check"
   2511 /* Obsoleted.     Access Control for Cross-site Requests */
   2512 #define MHD_HTTP_HEADER_METHOD_CHECK_EXPIRES "Method-Check-Expires"
   2513 /* Obsoleted.     RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */
   2514 #define MHD_HTTP_HEADER_OPT          "Opt"
   2515 /* Obsoleted.     The Platform for Privacy Preferences 1.0 (P3P1.0) Specification */
   2516 #define MHD_HTTP_HEADER_P3P          "P3P"
   2517 /* Obsoleted.     PEP - an Extension Mechanism for HTTP */
   2518 #define MHD_HTTP_HEADER_PEP          "PEP"
   2519 /* Obsoleted.     PEP - an Extension Mechanism for HTTP */
   2520 #define MHD_HTTP_HEADER_PEP_INFO     "Pep-Info"
   2521 /* Obsoleted.     PICS Label Distribution Label Syntax and Communication Protocols */
   2522 #define MHD_HTTP_HEADER_PICS_LABEL   "PICS-Label"
   2523 /* Obsoleted.     Implementation of OPS Over HTTP */
   2524 #define MHD_HTTP_HEADER_PROFILEOBJECT "ProfileObject"
   2525 /* Obsoleted.     PICS Label Distribution Label Syntax and Communication Protocols */
   2526 #define MHD_HTTP_HEADER_PROTOCOL     "Protocol"
   2527 /* Obsoleted.     PICS Label Distribution Label Syntax and Communication Protocols */
   2528 #define MHD_HTTP_HEADER_PROTOCOL_REQUEST "Protocol-Request"
   2529 /* Obsoleted.     Notification for Proxy Caches */
   2530 #define MHD_HTTP_HEADER_PROXY_FEATURES "Proxy-Features"
   2531 /* Obsoleted.     Notification for Proxy Caches */
   2532 #define MHD_HTTP_HEADER_PROXY_INSTRUCTION "Proxy-Instruction"
   2533 /* Obsoleted.     RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */
   2534 #define MHD_HTTP_HEADER_PUBLIC       "Public"
   2535 /* Obsoleted.     Access Control for Cross-site Requests */
   2536 #define MHD_HTTP_HEADER_REFERER_ROOT "Referer-Root"
   2537 /* Obsoleted.     RFC 2310: The Safe Response Header Field; status-change-http-experiments-to-historic */
   2538 #define MHD_HTTP_HEADER_SAFE         "Safe"
   2539 /* Obsoleted.     RFC 2660: The Secure HyperText Transfer Protocol; status-change-http-experiments-to-historic */
   2540 #define MHD_HTTP_HEADER_SECURITY_SCHEME "Security-Scheme"
   2541 /* Obsoleted.     RFC 2965: HTTP State Management Mechanism; RFC 6265: HTTP State Management Mechanism */
   2542 #define MHD_HTTP_HEADER_SET_COOKIE2  "Set-Cookie2"
   2543 /* Obsoleted.     Implementation of OPS Over HTTP */
   2544 #define MHD_HTTP_HEADER_SETPROFILE   "SetProfile"
   2545 /* Obsoleted.     RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */
   2546 #define MHD_HTTP_HEADER_URI          "URI"
   2547 /* Obsoleted.     RFC 3230: Instance Digests in HTTP; RFC-ietf-httpbis-digest-headers-13, Section 1.3: Digest Fields */
   2548 #define MHD_HTTP_HEADER_WANT_DIGEST  "Want-Digest"
   2549 /* Obsoleted.     RFC9111, Section 5.5: HTTP Caching */
   2550 #define MHD_HTTP_HEADER_WARNING      "Warning"
   2551 
   2552 /* Headers removed from the registry. Do not use! */
   2553 /* Obsoleted.     RFC4229 */
   2554 #define MHD_HTTP_HEADER_COMPLIANCE   "Compliance"
   2555 /* Obsoleted.     RFC4229 */
   2556 #define MHD_HTTP_HEADER_CONTENT_TRANSFER_ENCODING "Content-Transfer-Encoding"
   2557 /* Obsoleted.     RFC4229 */
   2558 #define MHD_HTTP_HEADER_COST         "Cost"
   2559 /* Obsoleted.     RFC4229 */
   2560 #define MHD_HTTP_HEADER_MESSAGE_ID   "Message-ID"
   2561 /* Obsoleted.     RFC4229 */
   2562 #define MHD_HTTP_HEADER_NON_COMPLIANCE "Non-Compliance"
   2563 /* Obsoleted.     RFC4229 */
   2564 #define MHD_HTTP_HEADER_OPTIONAL     "Optional"
   2565 /* Obsoleted.     RFC4229 */
   2566 #define MHD_HTTP_HEADER_RESOLUTION_HINT "Resolution-Hint"
   2567 /* Obsoleted.     RFC4229 */
   2568 #define MHD_HTTP_HEADER_RESOLVER_LOCATION "Resolver-Location"
   2569 /* Obsoleted.     RFC4229 */
   2570 #define MHD_HTTP_HEADER_SUBOK        "SubOK"
   2571 /* Obsoleted.     RFC4229 */
   2572 #define MHD_HTTP_HEADER_SUBST        "Subst"
   2573 /* Obsoleted.     RFC4229 */
   2574 #define MHD_HTTP_HEADER_TITLE        "Title"
   2575 /* Obsoleted.     RFC4229 */
   2576 #define MHD_HTTP_HEADER_UA_COLOR     "UA-Color"
   2577 /* Obsoleted.     RFC4229 */
   2578 #define MHD_HTTP_HEADER_UA_MEDIA     "UA-Media"
   2579 /* Obsoleted.     RFC4229 */
   2580 #define MHD_HTTP_HEADER_UA_PIXELS    "UA-Pixels"
   2581 /* Obsoleted.     RFC4229 */
   2582 #define MHD_HTTP_HEADER_UA_RESOLUTION "UA-Resolution"
   2583 /* Obsoleted.     RFC4229 */
   2584 #define MHD_HTTP_HEADER_UA_WINDOWPIXELS "UA-Windowpixels"
   2585 /* Obsoleted.     RFC4229 */
   2586 #define MHD_HTTP_HEADER_VERSION      "Version"
   2587 /* Obsoleted.     W3C Mobile Web Best Practices Working Group */
   2588 #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT "X-Device-Accept"
   2589 /* Obsoleted.     W3C Mobile Web Best Practices Working Group */
   2590 #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT_CHARSET "X-Device-Accept-Charset"
   2591 /* Obsoleted.     W3C Mobile Web Best Practices Working Group */
   2592 #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT_ENCODING "X-Device-Accept-Encoding"
   2593 /* Obsoleted.     W3C Mobile Web Best Practices Working Group */
   2594 #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT_LANGUAGE "X-Device-Accept-Language"
   2595 /* Obsoleted.     W3C Mobile Web Best Practices Working Group */
   2596 #define MHD_HTTP_HEADER_X_DEVICE_USER_AGENT "X-Device-User-Agent"
   2597 
   2598 
   2599 /**
   2600  * Predefined list of headers
   2601  * To be filled with HPACK static data
   2602  */
   2603 enum MHD_PredefinedHeader
   2604 {
   2605   MHD_PREDEF_ACCEPT_CHARSET = 15,
   2606   MHD_PREDEF_ACCEPT_LANGUAGE = 17
   2607 };
   2608 
   2609 
   2610 /** @} */ /* end of group headers */
   2611 
   2612 /**
   2613  * A client has requested the given url using the given method
   2614  * (#MHD_HTTP_METHOD_GET, #MHD_HTTP_METHOD_PUT,
   2615  * #MHD_HTTP_METHOD_DELETE, #MHD_HTTP_METHOD_POST, etc).
   2616  * If @a upload_size is not zero and response action is provided by this
   2617  * callback, then upload will be discarded and the stream (the connection for
   2618  * HTTP/1.1) will be closed after sending the response.
   2619  *
   2620  * @param cls argument given together with the function
   2621  *        pointer when the handler was registered with MHD
   2622  * @param request the request object
   2623  * @param path the requested uri (without arguments after "?")
   2624  * @param method the HTTP method used (#MHD_HTTP_METHOD_GET,
   2625  *        #MHD_HTTP_METHOD_PUT, etc.)
   2626  * @param upload_size the size of the message upload content payload,
   2627  *                    #MHD_SIZE_UNKNOWN for chunked uploads (if the
   2628  *                    final chunk has not been processed yet)
   2629  * @return action how to proceed, NULL
   2630  *         if the request must be aborted due to a serious
   2631  *         error while handling the request (implies closure
   2632  *         of underling data stream, for HTTP/1.1 it means
   2633  *         socket closure).
   2634  */
   2635 typedef const struct MHD_Action *
   2636 (MHD_FN_PAR_NONNULL_ (2) MHD_FN_PAR_NONNULL_ (3)
   2637  *MHD_RequestCallback)(void *cls,
   2638                        struct MHD_Request *MHD_RESTRICT request,
   2639                        const struct MHD_String *MHD_RESTRICT path,
   2640                        enum MHD_HTTP_Method method,
   2641                        uint_fast64_t upload_size);
   2642 
   2643 
   2644 /**
   2645  * Create (but do not yet start) an MHD daemon.
   2646  * Usually, various options are set before
   2647  * starting the daemon with #MHD_daemon_start().
   2648  *
   2649  * @param req_cb the function to be called for incoming requests
   2650  * @param req_cb_cls the closure for @a cb
   2651  * @return the pointer to the new object on success,
   2652  *         NULL on error (like out-of-memory)
   2653  */
   2654 MHD_EXTERN_ struct MHD_Daemon *
   2655 MHD_daemon_create (MHD_RequestCallback req_cb,
   2656                    void *req_cb_cls)
   2657 MHD_FN_MUST_CHECK_RESULT_;
   2658 
   2659 
   2660 /**
   2661  * Start a webserver.
   2662  * This function:
   2663  * + checks the combination of set options,
   2664  * + initialises the TLS library (if TLS is requested),
   2665  * + creates the listen socket (if not provided and if allowed),
   2666  * + starts the daemon internal threads (if allowed)
   2667  *
   2668  * @param[in,out] daemon daemon to start; you can no longer set
   2669  *        options on this daemon after this call!
   2670  * @return #MHD_SC_OK on success
   2671  * @ingroup daemon
   2672  */
   2673 MHD_EXTERN_ enum MHD_StatusCode
   2674 MHD_daemon_start (struct MHD_Daemon *daemon)
   2675 MHD_FN_PAR_NONNULL_ (1) MHD_FN_MUST_CHECK_RESULT_;
   2676 
   2677 
   2678 /**
   2679  * Stop accepting connections from the listening socket.  Allows
   2680  * clients to continue processing, but stops accepting new
   2681  * connections.  Note that the caller is responsible for closing the
   2682  * returned socket; however, if MHD is run using threads (anything but
   2683  * external select mode), it must not be closed until AFTER
   2684  * #MHD_daemon_destroy() has been called (as it is theoretically possible
   2685  * that an existing thread is still using it).
   2686  *
   2687  * @param[in,out] daemon the daemon to stop accepting new connections for
   2688  * @return the old listen socket on success, #MHD_INVALID_SOCKET if
   2689  *         the daemon was already not listening anymore, or
   2690  *         was never started, or has no listen socket.
   2691  * @ingroup daemon
   2692  */
   2693 MHD_EXTERN_ MHD_Socket
   2694 MHD_daemon_quiesce (struct MHD_Daemon *daemon)
   2695 MHD_FN_PAR_NONNULL_ALL_ MHD_FN_PAR_INOUT_ (1);
   2696 
   2697 
   2698 /**
   2699  * Shutdown and destroy an HTTP daemon.
   2700  *
   2701  * @param[in] daemon daemon to stop
   2702  * @ingroup daemon
   2703  */
   2704 MHD_EXTERN_ void
   2705 MHD_daemon_destroy (struct MHD_Daemon *daemon)
   2706 MHD_FN_PAR_NONNULL_ALL_;
   2707 
   2708 /* ******************* External event loop ************************ */
   2709 
   2710 /**
   2711  * @defgroup event External network events processing
   2712  */
   2713 
   2714 /**
   2715  * The network status of the socket.
   2716  * When set by MHD (by #MHD_SocketRegistrationUpdateCallback or
   2717  * similar) it indicates a request to watch for specific socket state:
   2718  * watch for readiness for receiving the data, watch for readiness for sending
   2719  * the data and/or watch for exception state of the socket.
   2720  * When set by application (and provided for #MHD_daemon_event_update() and
   2721  * similar) it must indicate the actual status of the socket.
   2722  *
   2723  * Any actual state is a bitwise OR combination of #MHD_FD_STATE_RECV,
   2724  * #MHD_FD_STATE_SEND, #MHD_FD_STATE_EXCEPT.
   2725  * @ingroup event
   2726  */
   2727 enum MHD_FIXED_ENUM_ MHD_FdState
   2728 {
   2729   /**
   2730    * The socket is not ready for receiving or sending and
   2731    * does not have any exceptional state.
   2732    * The state never set by MHD, except de-registration of the sockets
   2733    * in a #MHD_SocketRegistrationUpdateCallback.
   2734    */
   2735   MHD_FD_STATE_NONE = 0
   2736   ,
   2737   /* ** Three bit-flags ** */
   2738 
   2739   /**
   2740    * Indicates that socket should be watched for incoming data
   2741    * (when set by #MHD_SocketRegistrationUpdateCallback)
   2742    * / socket has incoming data ready to read (when used for
   2743    * #MHD_daemon_event_update())
   2744    */
   2745   MHD_FD_STATE_RECV = 1 << 0
   2746   ,
   2747   /**
   2748    * Indicates that socket should be watched for availability for sending
   2749    * (when set by #MHD_SocketRegistrationUpdateCallback)
   2750    * / socket has ability to send data (when used for
   2751    * #MHD_daemon_event_update())
   2752    */
   2753   MHD_FD_STATE_SEND = 1 << 1
   2754   ,
   2755   /**
   2756    * Indicates that socket should be watched for disconnect, out-of-band
   2757    * data available or high priority data available (when set by
   2758    * #MHD_SocketRegistrationUpdateCallback)
   2759    * / socket has been disconnected, has out-of-band data available or
   2760    * has high priority data available (when used for
   2761    * #MHD_daemon_event_update()). This status must not include "remote
   2762    * peer shut down writing" status.
   2763    * Note: #MHD_SocketRegistrationUpdateCallback() always set it as exceptions
   2764    * must be always watched.
   2765    */
   2766   MHD_FD_STATE_EXCEPT = 1 << 2
   2767   ,
   2768 
   2769   /* The rest of the list is a bit-wise combination of three main
   2770    * states. Application may use three main states directly as
   2771    * a bit-mask instead of using of the following values
   2772    */
   2773 
   2774   /**
   2775    * Combination of #MHD_FD_STATE_RECV and #MHD_FD_STATE_SEND states.
   2776    */
   2777   MHD_FD_STATE_RECV_SEND = MHD_FD_STATE_RECV | MHD_FD_STATE_SEND
   2778   ,
   2779   /**
   2780    * Combination of #MHD_FD_STATE_RECV and #MHD_FD_STATE_EXCEPT states.
   2781    */
   2782   MHD_FD_STATE_RECV_EXCEPT = MHD_FD_STATE_RECV | MHD_FD_STATE_EXCEPT
   2783   ,
   2784   /**
   2785    * Combination of #MHD_FD_STATE_RECV and #MHD_FD_STATE_EXCEPT states.
   2786    */
   2787   MHD_FD_STATE_SEND_EXCEPT = MHD_FD_STATE_RECV | MHD_FD_STATE_EXCEPT
   2788   ,
   2789   /**
   2790    * Combination of #MHD_FD_STATE_RECV, #MHD_FD_STATE_SEND and
   2791    * #MHD_FD_STATE_EXCEPT states.
   2792    */
   2793   MHD_FD_STATE_RECV_SEND_EXCEPT = \
   2794     MHD_FD_STATE_RECV | MHD_FD_STATE_SEND | MHD_FD_STATE_EXCEPT
   2795 };
   2796 
   2797 /**
   2798  * Checks whether specific @a state is enabled/set in the @a var
   2799  */
   2800 #define MHD_FD_STATE_IS_SET(var,state)               \
   2801         (MHD_FD_STATE_NONE !=                        \
   2802          ((enum MHD_FdState) (((unsigned int) (var)) \
   2803                               & ((unsigned int) (state)))))
   2804 
   2805 /**
   2806  * Checks whether RECV is enabled/set in the @a var
   2807  */
   2808 #define MHD_FD_STATE_IS_SET_RECV(var) \
   2809         MHD_FD_STATE_IS_SET ((var),MHD_FD_STATE_RECV)
   2810 /**
   2811  * Checks whether SEND is enabled/set in the @a var
   2812  */
   2813 #define MHD_FD_STATE_IS_SET_SEND(var) \
   2814         MHD_FD_STATE_IS_SET ((var),MHD_FD_STATE_SEND)
   2815 /**
   2816  * Checks whether EXCEPT is enabled/set in the @a var
   2817  */
   2818 #define MHD_FD_STATE_IS_SET_EXCEPT(var) \
   2819         MHD_FD_STATE_IS_SET ((var),MHD_FD_STATE_EXCEPT)
   2820 
   2821 
   2822 /**
   2823  * Set/enable specific @a state in the @a var
   2824  */
   2825 #define MHD_FD_STATE_SET(var,state) \
   2826         ((var) =                    \
   2827            (enum MHD_FdState) (((unsigned int) var) | ((unsigned int) state)))
   2828 /**
   2829  * Set/enable RECV state in the @a var
   2830  */
   2831 #define MHD_FD_STATE_SET_RECV(var) MHD_FD_STATE_SET ((var),MHD_FD_STATE_RECV)
   2832 /**
   2833  * Set/enable SEND state in the @a var
   2834  */
   2835 #define MHD_FD_STATE_SET_SEND(var) MHD_FD_STATE_SET ((var),MHD_FD_STATE_SEND)
   2836 /**
   2837  * Set/enable EXCEPT state in the @a var
   2838  */
   2839 #define MHD_FD_STATE_SET_EXCEPT(var) \
   2840         MHD_FD_STATE_SET ((var),MHD_FD_STATE_EXCEPT)
   2841 
   2842 /**
   2843  * Clear/disable specific @a state in the @a var
   2844  */
   2845 #define MHD_FD_STATE_CLEAR(var,state) \
   2846         ( (var) =                     \
   2847             (enum MHD_FdState)        \
   2848             (((unsigned int) var)     \
   2849              & ((enum MHD_FdState) (~((unsigned int) state)))) \
   2850         )
   2851 /**
   2852  * Clear/disable RECV state in the @a var
   2853  */
   2854 #define MHD_FD_STATE_CLEAR_RECV(var) \
   2855         MHD_FD_STATE_CLEAR ((var),MHD_FD_STATE_RECV)
   2856 /**
   2857  * Clear/disable SEND state in the @a var
   2858  */
   2859 #define MHD_FD_STATE_CLEAR_SEND(var) \
   2860         MHD_FD_STATE_CLEAR ((var),MHD_FD_STATE_SEND)
   2861 /**
   2862  * Clear/disable EXCEPT state in the @a var
   2863  */
   2864 #define MHD_FD_STATE_CLEAR_EXCEPT(var) \
   2865         MHD_FD_STATE_CLEAR ((var),MHD_FD_STATE_EXCEPT)
   2866 
   2867 
   2868 /**
   2869  * The context data to be used for updates of the socket state
   2870  */
   2871 struct MHD_EventUpdateContext;
   2872 
   2873 
   2874 /* Define MHD_APP_SOCKET_CNTX_TYPE to the socket context type before
   2875  * including this header.
   2876  * This is optional, but improves the types safety.
   2877  * For example:
   2878  * #define MHD_APP_SOCKET_CNTX_TYPE struct my_structure
   2879  */
   2880 #ifndef MHD_APP_SOCKET_CNTX_TYPE
   2881 #  define MHD_APP_SOCKET_CNTX_TYPE void
   2882 #endif
   2883 
   2884 /**
   2885  * The callback for registration/de-registration of the sockets to watch.
   2886  *
   2887  * This callback must not call #MHD_daemon_destroy(), #MHD_daemon_quiesce(),
   2888  * #MHD_daemon_add_connection().
   2889  *
   2890  * @param cls the closure
   2891  * @param fd the socket to watch
   2892  * @param watch_for the states of the @a fd to watch, if set to
   2893  *                  #MHD_FD_STATE_NONE the socket must be de-registred
   2894  * @param app_cntx_old the old application defined context for the socket,
   2895  *                     NULL if @a fd socket was not registered before
   2896  * @param ecb_cntx the context handle to be used
   2897  *                 with #MHD_daemon_event_update()
   2898  * @return must be NULL for the removed (de-registred) sockets,
   2899  *         for new and updated sockets: NULL in case of error (the connection
   2900  *         will be aborted or daemon failed to start if FD does not belong to
   2901  *         connection)
   2902  *         or the new socket context (opaque for MHD, must be non-NULL)
   2903  * @sa #MHD_D_OPTION_REREGISTER_ALL
   2904  * @ingroup event
   2905  */
   2906 typedef MHD_APP_SOCKET_CNTX_TYPE *
   2907 (MHD_FN_PAR_NONNULL_ (5)
   2908  *MHD_SocketRegistrationUpdateCallback)(
   2909   void *cls,
   2910   MHD_Socket fd,
   2911   enum MHD_FdState watch_for,
   2912   MHD_APP_SOCKET_CNTX_TYPE *app_cntx_old,
   2913   struct MHD_EventUpdateContext *ecb_cntx);
   2914 
   2915 
   2916 /**
   2917  * Update the sockets state.
   2918  * Must be called for every socket that got state updated.
   2919  * For #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL() mode
   2920  * this function must be called for each socket between any two calls of
   2921  * #MHD_daemon_process_reg_events() function.
   2922  * Available only for daemons started in
   2923  * #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL or
   2924  * #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE modes.
   2925  * @param daemon the daemon handle
   2926  * @param ecb_cntx the context handle provided
   2927  *                 for #MHD_SocketRegistrationUpdateCallback
   2928  * @param fd_current_state the current state of the socket
   2929  * @ingroup event
   2930  */
   2931 MHD_EXTERN_ void
   2932 MHD_daemon_event_update (
   2933   struct MHD_Daemon *MHD_RESTRICT daemon,
   2934   struct MHD_EventUpdateContext *MHD_RESTRICT ecb_cntx,
   2935   enum MHD_FdState fd_current_state)
   2936 MHD_FN_PAR_NONNULL_ (1) MHD_FN_PAR_NONNULL_ (2);
   2937 
   2938 
   2939 /**
   2940  * Perform all daemon activities based on FDs events provided earlier by
   2941  * application via #MHD_daemon_event_update().
   2942  *
   2943  * This function accepts new connections (if any), performs HTTP communications
   2944  * on all active connections, closes connections as needed and performs FDs
   2945  * registration updates by calling #MHD_SocketRegistrationUpdateCallback
   2946  * callback for every socket that needs to be added/updated/removed.
   2947  *
   2948  * Available only for daemons started in #MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL or
   2949  * #MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE modes.
   2950  *
   2951  * When used in #MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL mode, application must
   2952  * provide all updates by calling #MHD_daemon_event_update() for every
   2953  * registered FD between any two calls of this function.
   2954  *
   2955  * @param daemon the daemon handle
   2956  * @param[out] next_max_wait_milsec the optional pointer to receive the
   2957                                     next maximum wait time in milliseconds
   2958                                     to be used for the sockets polling
   2959                                     function, can be NULL
   2960  * @return #MHD_SC_OK on success,
   2961  *         error code otherwise
   2962  * @sa #MHD_D_OPTION_REREGISTER_ALL
   2963  * @ingroup event
   2964  */
   2965 MHD_EXTERN_ enum MHD_StatusCode
   2966 MHD_daemon_process_reg_events (
   2967   struct MHD_Daemon *MHD_RESTRICT daemon,
   2968   uint_fast64_t *MHD_RESTRICT next_max_wait_milsec)
   2969 MHD_FN_PAR_NONNULL_ (1);
   2970 
   2971 /* ********************* daemon options ************** */
   2972 
   2973 
   2974 /**
   2975  * Which threading and polling mode should be used by MHD?
   2976  */
   2977 enum MHD_FIXED_ENUM_APP_SET_ MHD_WorkMode
   2978 {
   2979   /**
   2980    * Work mode with no internal threads.
   2981    * The application periodically calls #MHD_daemon_process_blocking(), where
   2982    * MHD internally checks all sockets automatically.
   2983    * This is the default mode.
   2984    * Use helper macro #MHD_D_OPTION_WM_EXTERNAL_PERIODIC() to enable
   2985    * this mode.
   2986    */
   2987   MHD_WM_EXTERNAL_PERIODIC = 0
   2988   ,
   2989   /**
   2990    * Work mode with an external event loop with level triggers.
   2991    * MHD provides registration of all FDs to be monitored by using
   2992    * #MHD_SocketRegistrationUpdateCallback, application performs level triggered
   2993    * FDs polling (like select() or poll()), calls function
   2994    * #MHD_daemon_event_update() for every registered FD and then calls main
   2995    * function MHD_daemon_process_reg_events() to process the data.
   2996    * Use helper macro #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL() to enable
   2997    * this mode.
   2998    * @sa #MHD_D_OPTION_REREGISTER_ALL
   2999    */
   3000   MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL = 8
   3001   ,
   3002   /**
   3003    * Work mode with an external event loop with edge triggers.
   3004    * MHD provides registration of all FDs to be monitored by using
   3005    * #MHD_SocketRegistrationUpdateCallback, application performs edge triggered
   3006    * sockets polling (like epoll with EPOLLET), calls function
   3007    * #MHD_daemon_event_update() for FDs with updated states and then calls main
   3008    * function MHD_daemon_process_reg_events() to process the data.
   3009    * Use helper macro #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE() to enable
   3010    * this mode.
   3011    * @sa #MHD_D_OPTION_REREGISTER_ALL
   3012    */
   3013   MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE = 9
   3014   ,
   3015   /**
   3016    * Work mode with no internal threads and aggregate watch FD.
   3017    * Application uses #MHD_DAEMON_INFO_FIXED_AGGREAGATE_FD to get single FD
   3018    * that gets triggered by any MHD event.
   3019    * This FD can be watched as an aggregate indicator for all MHD events.
   3020    * This mode is available only on selected platforms (currently
   3021    * GNU/Linux and OpenIndiana only), see #MHD_LIB_INFO_FIXED_HAS_AGGREGATE_FD.
   3022    * When the FD is triggered, #MHD_daemon_process_nonblocking() should
   3023    * be called.
   3024    * Use helper macro #MHD_D_OPTION_WM_EXTERNAL_SINGLE_FD_WATCH() to enable
   3025    * this mode.
   3026    */
   3027   MHD_WM_EXTERNAL_SINGLE_FD_WATCH = 16
   3028   ,
   3029   /**
   3030    * Work mode with one or more worker threads.
   3031    * If specified number of threads is one, then daemon starts with single
   3032    * worker thread that handles all connections.
   3033    * If number of threads is larger than one, then that number of worker
   3034    * threads, and handling of connection is distributed among the workers.
   3035    * Use helper macro #MHD_D_OPTION_WM_WORKER_THREADS() to enable
   3036    * this mode.
   3037    */
   3038   MHD_WM_WORKER_THREADS = 24
   3039   ,
   3040   /**
   3041    * Work mode with one internal thread for listening and additional threads
   3042    * per every connection.  Use this if handling requests is CPU-intensive or
   3043    * blocking, your application is thread-safe and you have plenty of
   3044    * memory (per connection).
   3045    * Use helper macro #MHD_D_OPTION_WM_THREAD_PER_CONNECTION() to enable
   3046    * this mode.
   3047    */
   3048   MHD_WM_THREAD_PER_CONNECTION = 32
   3049 };
   3050 
   3051 /**
   3052  * Work mode parameters for #MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL and
   3053  * #MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE modes
   3054  */
   3055 struct MHD_WorkModeExternalEventLoopCBParam
   3056 {
   3057   /**
   3058    * Socket registration callback
   3059    */
   3060   MHD_SocketRegistrationUpdateCallback reg_cb;
   3061   /**
   3062    * Closure for the @a reg_cb
   3063    */
   3064   void *reg_cb_cls;
   3065 };
   3066 
   3067 /**
   3068  * MHD work mode parameters
   3069  */
   3070 union MHD_WorkModeParam
   3071 {
   3072   /**
   3073    * Work mode parameters for #MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL and
   3074    * #MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE modes
   3075    */
   3076   struct MHD_WorkModeExternalEventLoopCBParam v_external_event_loop_cb;
   3077   /**
   3078    * Number of worker threads for #MHD_WM_WORKER_THREADS.
   3079    * If set to one, then daemon starts with single worker thread that process
   3080    * all connections.
   3081    * If set to value larger than one, then that number of worker threads
   3082    * and distributed handling of requests among the workers.
   3083    * Zero is treated as one.
   3084    */
   3085   unsigned int num_worker_threads;
   3086 };
   3087 
   3088 /**
   3089  * Parameter for #MHD_D_O_WORK_MODE().
   3090  * Not recommended to be used directly, better use macro/functions to create it:
   3091  * #MHD_WM_OPTION_EXTERNAL_PERIODIC(),
   3092  * #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(),
   3093  * #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(),
   3094  * #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(),
   3095  * #MHD_WM_OPTION_WORKER_THREADS(),
   3096  * #MHD_WM_OPTION_THREAD_PER_CONNECTION()
   3097  */
   3098 struct MHD_WorkModeWithParam
   3099 {
   3100   /**
   3101    * The work mode for MHD
   3102    */
   3103   enum MHD_WorkMode mode;
   3104   /**
   3105    * The parameters used for specified work mode
   3106    */
   3107   union MHD_WorkModeParam params;
   3108 };
   3109 
   3110 
   3111 #if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_DESIG_NEST_INIT)
   3112 /**
   3113  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3114  * no internal threads.
   3115  * The application periodically calls #MHD_daemon_process_blocking(), where
   3116  * MHD internally checks all sockets automatically.
   3117  * This is the default mode.
   3118  * @return the object of struct MHD_WorkModeWithParam with requested values
   3119  */
   3120 #  define MHD_WM_OPTION_EXTERNAL_PERIODIC()     \
   3121         MHD_NOWARN_COMPOUND_LITERALS_                 \
   3122           (const struct MHD_WorkModeWithParam)          \
   3123         {                                             \
   3124           .mode = (MHD_WM_EXTERNAL_PERIODIC)          \
   3125         }                                             \
   3126         MHD_RESTORE_WARN_COMPOUND_LITERALS_
   3127 
   3128 /**
   3129  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3130  * an external event loop with level triggers.
   3131  * Application uses #MHD_SocketRegistrationUpdateCallback, level triggered
   3132  * sockets polling (like select() or poll()) and #MHD_daemon_event_update().
   3133  * @param cb_val the callback for sockets registration
   3134  * @param cb_cls_val the closure for the @a cv_val callback
   3135  * @return the object of struct MHD_WorkModeWithParam with requested values
   3136  */
   3137 #  define MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(cb_val,cb_cls_val) \
   3138         MHD_NOWARN_COMPOUND_LITERALS_                                         \
   3139           (const struct MHD_WorkModeWithParam)                                  \
   3140         {                                                                     \
   3141           .mode = (MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL),                      \
   3142           .params.v_external_event_loop_cb.reg_cb = (cb_val),                 \
   3143           .params.v_external_event_loop_cb.reg_cb_cls = (cb_cls_val)          \
   3144         }                                                                     \
   3145         MHD_RESTORE_WARN_COMPOUND_LITERALS_
   3146 
   3147 /**
   3148  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3149  * an external event loop with edge triggers.
   3150  * Application uses #MHD_SocketRegistrationUpdateCallback, edge triggered
   3151  * sockets polling (like epoll with EPOLLET) and #MHD_daemon_event_update().
   3152  * @param cb_val the callback for sockets registration
   3153  * @param cb_cls_val the closure for the @a cv_val callback
   3154  * @return the object of struct MHD_WorkModeWithParam with requested values
   3155  */
   3156 #  define MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(cb_val,cb_cls_val)  \
   3157         MHD_NOWARN_COMPOUND_LITERALS_                                         \
   3158           (const struct MHD_WorkModeWithParam)                                  \
   3159         {                                                                     \
   3160           .mode = (MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE),                       \
   3161           .params.v_external_event_loop_cb.reg_cb = (cb_val),                 \
   3162           .params.v_external_event_loop_cb.reg_cb_cls = (cb_cls_val)          \
   3163         }                                                                     \
   3164         MHD_RESTORE_WARN_COMPOUND_LITERALS_
   3165 
   3166 /**
   3167  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3168  * no internal threads and aggregate watch FD.
   3169  * Application uses #MHD_DAEMON_INFO_FIXED_AGGREAGATE_FD to get single FD
   3170  * that gets triggered by any MHD event.
   3171  * This FD can be watched as an aggregate indicator for all MHD events.
   3172  * This mode is available only on selected platforms (currently
   3173  * GNU/Linux only), see #MHD_LIB_INFO_FIXED_HAS_AGGREGATE_FD.
   3174  * When the FD is triggered, #MHD_daemon_process_nonblocking() should
   3175  * be called.
   3176  * @return the object of struct MHD_WorkModeWithParam with requested values
   3177  */
   3178 #  define MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH()      \
   3179         MHD_NOWARN_COMPOUND_LITERALS_                         \
   3180           (const struct MHD_WorkModeWithParam)                  \
   3181         {                                                     \
   3182           .mode = (MHD_WM_EXTERNAL_SINGLE_FD_WATCH)           \
   3183         }                                                     \
   3184         MHD_RESTORE_WARN_COMPOUND_LITERALS_
   3185 
   3186 /**
   3187  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3188  * one or more worker threads.
   3189  * If number of threads is one, then daemon starts with single worker thread
   3190  * that handles all connections.
   3191  * If number of threads is larger than one, then that number of worker threads,
   3192  * and handling of connection is distributed among the workers.
   3193  * @param num_workers the number of worker threads, zero is treated as one
   3194  * @return the object of struct MHD_WorkModeWithParam with requested values
   3195  */
   3196 #  define MHD_WM_OPTION_WORKER_THREADS(num_workers)     \
   3197         MHD_NOWARN_COMPOUND_LITERALS_                         \
   3198           (const struct MHD_WorkModeWithParam)                  \
   3199         {                                                     \
   3200           .mode = (MHD_WM_WORKER_THREADS),                    \
   3201           .params.num_worker_threads = (num_workers)          \
   3202         }                                                     \
   3203         MHD_RESTORE_WARN_COMPOUND_LITERALS_
   3204 
   3205 /**
   3206  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3207  * one internal thread for listening and additional threads per every
   3208  * connection.  Use this if handling requests is CPU-intensive or blocking,
   3209  * your application is thread-safe and you have plenty of memory (per
   3210  * connection).
   3211  * @return the object of struct MHD_WorkModeWithParam with requested values
   3212  */
   3213 #  define MHD_WM_OPTION_THREAD_PER_CONNECTION() \
   3214         MHD_NOWARN_COMPOUND_LITERALS_                 \
   3215           (const struct MHD_WorkModeWithParam)          \
   3216         {                                             \
   3217           .mode = (MHD_WM_THREAD_PER_CONNECTION)      \
   3218         }                                             \
   3219         MHD_RESTORE_WARN_COMPOUND_LITERALS_
   3220 
   3221 #else  /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
   3222 MHD_NOWARN_UNUSED_FUNC_
   3223 
   3224 /**
   3225  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3226  * no internal threads.
   3227  * The application periodically calls #MHD_daemon_process_blocking(), where
   3228  * MHD internally checks all sockets automatically.
   3229  * This is the default mode.
   3230  * @return the object of struct MHD_WorkModeWithParam with requested values
   3231  */
   3232 static MHD_INLINE struct MHD_WorkModeWithParam
   3233 MHD_WM_OPTION_EXTERNAL_PERIODIC (void)
   3234 {
   3235   struct MHD_WorkModeWithParam wm_val;
   3236 
   3237   wm_val.mode = MHD_WM_EXTERNAL_PERIODIC;
   3238 
   3239   return wm_val;
   3240 }
   3241 
   3242 
   3243 /**
   3244  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3245  * an external event loop with level triggers.
   3246  * Application uses #MHD_SocketRegistrationUpdateCallback, level triggered
   3247  * sockets polling (like select() or poll()) and #MHD_daemon_event_update().
   3248  * @param cb_val the callback for sockets registration
   3249  * @param cb_cls_val the closure for the @a cv_val callback
   3250  * @return the object of struct MHD_WorkModeWithParam with requested values
   3251  */
   3252 static MHD_INLINE struct MHD_WorkModeWithParam
   3253 MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL (
   3254   MHD_SocketRegistrationUpdateCallback cb_val,
   3255   void *cb_cls_val)
   3256 {
   3257   struct MHD_WorkModeWithParam wm_val;
   3258 
   3259   wm_val.mode = MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL;
   3260   wm_val.params.v_external_event_loop_cb.reg_cb = cb_val;
   3261   wm_val.params.v_external_event_loop_cb.reg_cb_cls = cb_cls_val;
   3262 
   3263   return wm_val;
   3264 }
   3265 
   3266 
   3267 /**
   3268  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3269  * an external event loop with edge triggers.
   3270  * Application uses #MHD_SocketRegistrationUpdateCallback, edge triggered
   3271  * sockets polling (like epoll with EPOLLET) and #MHD_daemon_event_update().
   3272  * @param cb_val the callback for sockets registration
   3273  * @param cb_cls_val the closure for the @a cv_val callback
   3274  * @return the object of struct MHD_WorkModeWithParam with requested values
   3275  */
   3276 static MHD_INLINE struct MHD_WorkModeWithParam
   3277 MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE (
   3278   MHD_SocketRegistrationUpdateCallback cb_val,
   3279   void *cb_cls_val)
   3280 {
   3281   struct MHD_WorkModeWithParam wm_val;
   3282 
   3283   wm_val.mode = MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE;
   3284   wm_val.params.v_external_event_loop_cb.reg_cb = cb_val;
   3285   wm_val.params.v_external_event_loop_cb.reg_cb_cls = cb_cls_val;
   3286 
   3287   return wm_val;
   3288 }
   3289 
   3290 
   3291 /**
   3292  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3293  * no internal threads and aggregate watch FD.
   3294  * Application uses #MHD_DAEMON_INFO_FIXED_AGGREAGATE_FD to get single FD
   3295  * that gets triggered by any MHD event.
   3296  * This FD can be watched as an aggregate indicator for all MHD events.
   3297  * This mode is available only on selected platforms (currently
   3298  * GNU/Linux only), see #MHD_LIB_INFO_FIXED_HAS_AGGREGATE_FD.
   3299  * When the FD is triggered, #MHD_daemon_process_nonblocking() should
   3300  * be called.
   3301  * @return the object of struct MHD_WorkModeWithParam with requested values
   3302  */
   3303 static MHD_INLINE struct MHD_WorkModeWithParam
   3304 MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH (void)
   3305 {
   3306   struct MHD_WorkModeWithParam wm_val;
   3307 
   3308   wm_val.mode = MHD_WM_EXTERNAL_SINGLE_FD_WATCH;
   3309 
   3310   return wm_val;
   3311 }
   3312 
   3313 
   3314 /**
   3315  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3316  * one or more worker threads.
   3317  * If number of threads is one, then daemon starts with single worker thread
   3318  * that handles all connections.
   3319  * If number of threads is larger than one, then that number of worker threads,
   3320  * and handling of connection is distributed among the workers.
   3321  * @param num_workers the number of worker threads, zero is treated as one
   3322  * @return the object of struct MHD_WorkModeWithParam with requested values
   3323  */
   3324 static MHD_INLINE struct MHD_WorkModeWithParam
   3325 MHD_WM_OPTION_WORKER_THREADS (unsigned int num_workers)
   3326 {
   3327   struct MHD_WorkModeWithParam wm_val;
   3328 
   3329   wm_val.mode = MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE;
   3330   wm_val.params.num_worker_threads = num_workers;
   3331 
   3332   return wm_val;
   3333 }
   3334 
   3335 
   3336 /**
   3337  * Create parameter for #MHD_D_O_WORK_MODE() for work mode with
   3338  * one internal thread for listening and additional threads per every
   3339  * connection.  Use this if handling requests is CPU-intensive or blocking,
   3340  * your application is thread-safe and you have plenty of memory (per
   3341  * connection).
   3342  * @return the object of struct MHD_WorkModeWithParam with requested values
   3343  */
   3344 static MHD_INLINE struct MHD_WorkModeWithParam
   3345 MHD_WM_OPTION_THREAD_PER_CONNECTION (void)
   3346 {
   3347   struct MHD_WorkModeWithParam wm_val;
   3348 
   3349   wm_val.mode = MHD_WM_THREAD_PER_CONNECTION;
   3350 
   3351   return wm_val;
   3352 }
   3353 
   3354 
   3355 MHD_RESTORE_WARN_UNUSED_FUNC_
   3356 #endif /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
   3357 
   3358 /**
   3359  * @defgroup logging Log events and control
   3360  */
   3361 
   3362 
   3363 /**
   3364  * Type of a callback function used for logging by MHD.
   3365  *
   3366  * @param cls closure
   3367  * @param sc status code of the event
   3368  * @param fm format string (`printf()`-style)
   3369  * @param ap arguments to @a fm
   3370  * @ingroup logging
   3371  */
   3372 typedef void
   3373 (MHD_FN_PAR_NONNULL_ (3)
   3374  MHD_FN_PAR_CSTR_ (3)
   3375  *MHD_LoggingCallback)(void *cls,
   3376                        enum MHD_StatusCode sc,
   3377                        const char *fm,
   3378                        va_list ap);
   3379 
   3380 /**
   3381  * Parameter for listen socket binding type
   3382  */
   3383 enum MHD_FIXED_ENUM_APP_SET_ MHD_DaemonOptionBindType
   3384 {
   3385   /**
   3386    * The listen socket bind to the networks address with sharing the address.
   3387    * Several sockets can bind to the same address.
   3388    */
   3389   MHD_D_OPTION_BIND_TYPE_SHARED = -1
   3390   ,
   3391   /**
   3392    * The listen socket bind to the networks address without sharing the address,
   3393    * except allowing binding to port/address which has TIME_WAIT state (the
   3394    * state after closing connection).
   3395    * On some platforms it may also allow to bind to specific address if other
   3396    * socket already bond to the same port of wildcard address (or bind to
   3397    * wildcard address when other socket already bond to specific address
   3398    * with the same port).
   3399    * Typically achieved by enabling 'SO_REUSEADDR' socket option.
   3400    * Default.
   3401    */
   3402   MHD_D_OPTION_BIND_TYPE_NOT_SHARED = 0
   3403   ,
   3404   /**
   3405    * The listen socket bind to the networks address without sharing the address.
   3406    * The daemon way fail to start when any sockets still in "TIME_WAIT" state
   3407    * on the same port, which effectively prevents quick restart of the daemon
   3408    * on the same port.
   3409    * On W32 systems it works like #MHD_D_OPTION_BIND_TYPE_NOT_SHARED due to
   3410    * the OS limitations.
   3411    */
   3412   MHD_D_OPTION_BIND_TYPE_NOT_SHARED_STRICTER = 1
   3413   ,
   3414   /**
   3415    * The list socket bind to the networks address in explicit exclusive mode.
   3416    * Works as #MHD_D_OPTION_BIND_TYPE_NOT_SHARED_STRICTER on platforms without
   3417    * support for the explicit exclusive socket use.
   3418    */
   3419   MHD_D_OPTION_BIND_TYPE_EXCLUSIVE = 2
   3420 };
   3421 
   3422 
   3423 /**
   3424  * Possible levels of enforcement for TCP_FASTOPEN.
   3425  */
   3426 enum MHD_FIXED_ENUM_APP_SET_ MHD_TCPFastOpenType
   3427 {
   3428   /**
   3429    * Disable use of TCP_FASTOPEN.
   3430    */
   3431   MHD_FOM_DISABLE = -1
   3432   ,
   3433   /**
   3434    * Enable TCP_FASTOPEN where supported.
   3435    * On GNU/Linux it works with a kernel >= 3.6.
   3436    * This is the default.
   3437    */
   3438   MHD_FOM_AUTO = 0
   3439   ,
   3440   /**
   3441    * Require TCP_FASTOPEN.
   3442    * Also causes #MHD_daemon_start() to fail if TCP_FASTOPEN cannot be enabled.
   3443    */
   3444   MHD_FOM_REQUIRE = 1
   3445 };
   3446 
   3447 
   3448 /**
   3449  * Address family to be used by MHD.
   3450  */
   3451 enum MHD_FIXED_ENUM_APP_SET_ MHD_AddressFamily
   3452 {
   3453   /**
   3454    * Option not given, do not listen at all
   3455    * (unless listen socket or address specified by
   3456    * other means).
   3457    */
   3458   MHD_AF_NONE = 0
   3459   ,
   3460   /**
   3461    * Pick "best" available method automatically.
   3462    */
   3463   MHD_AF_AUTO = 1
   3464   ,
   3465   /**
   3466    * Use IPv4 only.
   3467    */
   3468   MHD_AF_INET4 = 2
   3469   ,
   3470   /**
   3471    * Use IPv6 only.
   3472    */
   3473   MHD_AF_INET6 = 3
   3474   ,
   3475   /**
   3476    * Use dual stack (IPv4 and IPv6 on the same socket).
   3477    */
   3478   MHD_AF_DUAL = 4
   3479   ,
   3480   /**
   3481    * Use dual stack (IPv4 and IPv6 on the same socket),
   3482    * fallback to pure IPv6 if dual stack is not possible.
   3483    */
   3484   MHD_AF_DUAL_v4_OPTIONAL = 5
   3485   ,
   3486   /**
   3487    * Use dual stack (IPv4 and IPv6 on the same socket),
   3488    * fallback to pure IPv4 if dual stack is not possible.
   3489    */
   3490   MHD_AF_DUAL_v6_OPTIONAL = 6
   3491 
   3492 };
   3493 
   3494 
   3495 /**
   3496  * Sockets polling internal syscalls used by MHD.
   3497  */
   3498 enum MHD_FIXED_ENUM_APP_SET_ MHD_SockPollSyscall
   3499 {
   3500   /**
   3501    * Automatic selection of best-available method. This is also the
   3502    * default.
   3503    */
   3504   MHD_SPS_AUTO = 0
   3505   ,
   3506   /**
   3507    * Use select().
   3508    */
   3509   MHD_SPS_SELECT = 1
   3510   ,
   3511   /**
   3512    * Use poll().
   3513    */
   3514   MHD_SPS_POLL = 2
   3515   ,
   3516   /**
   3517    * Use epoll.
   3518    */
   3519   MHD_SPS_EPOLL = 3
   3520   ,
   3521   /**
   3522    * Use kqueue.
   3523    */
   3524   MHD_SPS_KQUEUE = 4
   3525 };
   3526 
   3527 
   3528 /**
   3529  * Protocol strictness levels enforced by MHD on clients.
   3530  * Each level applies different parsing settings for HTTP headers and other
   3531  * protocol elements.
   3532  */
   3533 enum MHD_FIXED_ENUM_APP_SET_ MHD_ProtocolStrictLevel
   3534 {
   3535 
   3536   /* * Basic levels * */
   3537   /**
   3538    * A sane default level of protocol enforcement for production use.
   3539    * Provides a balance between enhanced security and broader compatibility,
   3540    * as permitted by RFCs for HTTP servers.
   3541    */
   3542   MHD_PSL_DEFAULT = 0
   3543   ,
   3544   /**
   3545    * Apply stricter protocol interpretation while remaining within
   3546    * RFC-defined limits for HTTP servers.
   3547    *
   3548    * At this level (and stricter), using a bare LF instead of CRLF is forbidden,
   3549    * and requests that include both a "Transfer-Encoding:" and
   3550    * a "Content-Length:" headers are rejected.
   3551    *
   3552    * Suitable for public servers.
   3553    */
   3554   MHD_PSL_STRICT = 1
   3555   ,
   3556   /**
   3557    * Be more permissive in interpreting the protocol, while still
   3558    * operating within the RFC-defined limits for HTTP servers.
   3559    */
   3560   MHD_PSL_PERMISSIVE = -1
   3561   ,
   3562   /* * Special levels * */
   3563   /**
   3564    * A stricter protocol interpretation than what is allowed by RFCs for HTTP
   3565    * servers. However, it should remain fully compatible with clients correctly
   3566    * following all RFC "MUST" requirements for HTTP clients.
   3567    *
   3568    * For chunked encoding, this level (and more restrictive ones) forbids
   3569    * whitespace in chunk extensions.
   3570    * For cookie parsing, this level (and more restrictive ones) rejects
   3571    * the entire cookie if even a single value within it is incorrectly encoded.
   3572    *
   3573    * Recommended for testing clients against MHD. Can also be used for
   3574    * security-centric applications, though doing so slightly violates
   3575    * relevant RFC requirements for HTTP servers.
   3576    */
   3577   MHD_PSL_VERY_STRICT = 2
   3578   ,
   3579   /**
   3580    * The strictest interpretation of the HTTP protocol, even stricter than
   3581    * allowed by RFCs for HTTP servers.
   3582    * However, it should remain fully compatible with clients complying with both
   3583    * RFC "SHOULD" and "MUST" requirements for HTTP clients.
   3584    *
   3585    * This level can be used for testing clients against MHD.
   3586    * It is not recommended for public services, as it may reject legitimate
   3587    * clients that do not follow RFC "SHOULD" requirements.
   3588    */
   3589   MHD_PSL_EXTRA_STRICT = 3
   3590   ,
   3591   /**
   3592    * A more relaxed protocol interpretation that violates some RFC "SHOULD"
   3593    * restrictions for HTTP servers.
   3594    * For cookie parsing, this level (and more permissive levels) allows
   3595    * whitespace in cookie values.
   3596    *
   3597    * This level may be used in isolated environments.
   3598    */
   3599   MHD_PSL_VERY_PERMISSIVE = -2
   3600   ,
   3601   /**
   3602    * The most flexible protocol interpretation, going beyond RFC "MUST"
   3603    * requirements for HTTP servers.
   3604    *
   3605    * This level allows HTTP/1.1 requests without a "Host:" header.
   3606    * For cookie parsing, whitespace is allowed before and after
   3607    * the '=' character.
   3608    *
   3609    * Not recommended unless absolutely necessary to communicate with clients
   3610    * that have severely broken HTTP implementations.
   3611    */
   3612   MHD_PSL_EXTRA_PERMISSIVE = -3,
   3613 };
   3614 
   3615 /**
   3616  * The way Strict Level is enforced.
   3617  * MHD can be compiled with limited set of strictness levels.
   3618  * These values instructs MHD how to apply the request level.
   3619  */
   3620 enum MHD_FIXED_ENUM_APP_SET_ MHD_UseStictLevel
   3621 {
   3622   /**
   3623    * Use requested level if available or the nearest stricter
   3624    * level.
   3625    * Fail if only more permissive levels available.
   3626    * Recommended value.
   3627    */
   3628   MHD_USL_THIS_OR_STRICTER = 0
   3629   ,
   3630   /**
   3631    * Use requested level only.
   3632    * Fail if this level is not available.
   3633    */
   3634   MHD_USL_PRECISE = 1
   3635   ,
   3636   /**
   3637    * Use requested level if available or the nearest level (stricter
   3638    * or more permissive).
   3639    */
   3640   MHD_USL_NEAREST = 2
   3641 };
   3642 
   3643 
   3644 /**
   3645  * Connection memory buffer zeroing mode.
   3646  * Works as a hardening measure.
   3647  */
   3648 enum MHD_FIXED_ENUM_APP_SET_ MHD_ConnBufferZeroingMode
   3649 {
   3650   /**
   3651    * Do not perform zeroing of connection memory buffer.
   3652    * Default mode.
   3653    */
   3654   MHD_CONN_BUFFER_ZEROING_DISABLED = 0
   3655   ,
   3656   /**
   3657    * Perform connection memory buffer zeroing before processing request.
   3658    */
   3659   MHD_CONN_BUFFER_ZEROING_BASIC = 1
   3660   ,
   3661   /**
   3662    * Perform connection memory buffer zeroing before processing request and
   3663    * when reusing buffer memory areas during processing request.
   3664    */
   3665   MHD_CONN_BUFFER_ZEROING_HEAVY = 2
   3666 };
   3667 
   3668 
   3669 /* ********************** (d) TLS support ********************** */
   3670 
   3671 /**
   3672  * The TLS backend choice
   3673  */
   3674 enum MHD_FIXED_ENUM_APP_SET_ MHD_TlsBackend
   3675 {
   3676   /**
   3677    * Disable TLS, use plain TCP connections (default)
   3678    */
   3679   MHD_TLS_BACKEND_NONE = 0
   3680   ,
   3681   /**
   3682    * Use best available TLS backend.
   3683    */
   3684   MHD_TLS_BACKEND_ANY = 1
   3685   ,
   3686   /**
   3687    * Use GnuTLS as TLS backend.
   3688    */
   3689   MHD_TLS_BACKEND_GNUTLS = 2
   3690   ,
   3691   /**
   3692    * Use OpenSSL as TLS backend.
   3693    */
   3694   MHD_TLS_BACKEND_OPENSSL = 3
   3695   ,
   3696   /**
   3697    * Use MbedTLS as TLS backend.
   3698    */
   3699   MHD_TLS_BACKEND_MBEDTLS = 4
   3700 };
   3701 
   3702 /**
   3703  * Values for #MHD_D_O_DAUTH_NONCE_BIND_TYPE.
   3704  *
   3705  * These values can limit the scope of validity of MHD-generated nonces.
   3706  * Values can be combined with bitwise OR.
   3707  * Any value, except #MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_NONE, enforce function
   3708  * #MHD_digest_auth_check() (and similar functions) to check nonce by
   3709  * re-generating it again with the same parameters, which is CPU-intensive
   3710  * operation.
   3711  */
   3712 enum MHD_FIXED_FLAGS_ENUM_APP_SET_ MHD_DaemonOptionValueDAuthBindNonce
   3713 {
   3714   /**
   3715    * Generated nonces are valid for any request from any client until expired.
   3716    * This is default and recommended value.
   3717    * #MHD_digest_auth_check() (and similar functions) would check only whether
   3718    * the nonce value that is used by client has been generated by MHD and not
   3719    * expired yet.
   3720    * It is recommended because RFC 7616 allows clients to use the same nonce
   3721    * for any request in the same "protection space".
   3722    * When checking client's authorisation requests CPU is loaded less if this
   3723    * value is used.
   3724    * This mode gives MHD maximum flexibility for nonces generation and can
   3725    * prevent possible nonce collisions (and corresponding log warning messages)
   3726    * when clients' requests are intensive.
   3727    * This value cannot be biwise-OR combined with other values.
   3728    */
   3729   MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_NONE = 0
   3730   ,
   3731   /**
   3732    * Generated nonces are valid only for the same realm.
   3733    */
   3734   MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_REALM = (1 << 0)
   3735   ,
   3736   /**
   3737    * Generated nonces are valid only for the same URI (excluding parameters
   3738    * after '?' in URI) and request method (GET, POST etc).
   3739    * Not recommended unless "protection space" is limited to a single URI as
   3740    * RFC 7616 allows clients to reuse server-generated nonces for any URI
   3741    * in the same "protection space" which by default consists of all server
   3742    * URIs.
   3743    */
   3744   MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_URI = (1 << 1)
   3745   ,
   3746 
   3747   /**
   3748    * Generated nonces are valid only for the same URI including URI parameters
   3749    * and request method (GET, POST etc).
   3750    * This value implies #MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_URI.
   3751    * Not recommended for that same reasons as
   3752    * #MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_URI.
   3753    */
   3754   MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_URI_PARAMS = (1 << 2)
   3755   ,
   3756 
   3757   /**
   3758    * Generated nonces are valid only for the single client's IP.
   3759    * While it looks like security improvement, in practice the same client may
   3760    * jump from one IP to another (mobile or Wi-Fi handover, DHCP re-assignment,
   3761    * Multi-NAT, different proxy chain and other reasons), while IP address
   3762    * spoofing could be used relatively easily.
   3763    */
   3764   MHD_D_OPTION_VALUE_DAUTH_BIND_NONCE_CLIENT_IP = (1 << 3)
   3765 };
   3766 
   3767 
   3768 struct MHD_ServerCredentialsContext;
   3769 
   3770 
   3771 /**
   3772  * Context required to provide a pre-shared key to the
   3773  * server.
   3774  *
   3775  * @param mscc the context
   3776  * @param psk_size the number of bytes in @a psk
   3777  * @param psk the pre-shared-key; should be allocated with malloc(),
   3778  *                 will be freed by MHD
   3779  */
   3780 MHD_EXTERN_ enum MHD_StatusCode
   3781 MHD_connection_set_psk (
   3782   struct MHD_ServerCredentialsContext *mscc,
   3783   size_t psk_size,
   3784   const /*void? */ char psk[MHD_FN_PAR_DYN_ARR_SIZE_ (psk_size)]);
   3785 
   3786 #define MHD_connection_set_psk_unavailable(mscc) \
   3787         MHD_connection_set_psk (mscc, 0, NULL)
   3788 
   3789 
   3790 /**
   3791  * Function called to lookup the pre-shared key (PSK) for a given
   3792  * HTTP connection based on the @a username.  MHD will suspend handling of
   3793  * the @a connection until the application calls #MHD_connection_set_psk().
   3794  * If looking up the PSK fails, the application must still call
   3795  * #MHD_connection_set_psk_unavailable().
   3796  *
   3797  * @param cls closure
   3798  * @param connection the HTTPS connection
   3799  * @param username the user name claimed by the other side
   3800  * @param mscc context to pass to #MHD_connection_set_psk().
   3801  */
   3802 typedef void
   3803 (*MHD_PskServerCredentialsCallback)(
   3804   void *cls,
   3805   const struct MHD_Connection *MHD_RESTRICT connection,
   3806   const struct MHD_String *MHD_RESTRICT username,
   3807   struct MHD_ServerCredentialsContext *mscc);
   3808 
   3809 
   3810 /**
   3811  * The specified callback will be called one time,
   3812  * after network initialisation, TLS pre-initialisation, but before
   3813  * the start of the internal threads (if allowed).
   3814  *
   3815  * This callback may use introspection call to retrieve and adjust
   3816  * some of the daemon aspects. For example, TLS backend handler can be used
   3817  * to configure some TLS aspects.
   3818  * @param cls the callback closure
   3819  */
   3820 typedef void
   3821 (*MHD_DaemonReadyCallback)(void *cls);
   3822 
   3823 
   3824 /**
   3825  * Allow or deny a client to connect.
   3826  *
   3827  * @param cls closure
   3828  * @param addr_len length of @a addr
   3829  * @param addr address information from the client
   3830  * @see #MHD_D_OPTION_ACCEPT_POLICY()
   3831  * @return #MHD_YES if connection is allowed, #MHD_NO if not
   3832  */
   3833 typedef enum MHD_Bool
   3834 (*MHD_AcceptPolicyCallback)(void *cls,
   3835                             size_t addr_len,
   3836                             const struct sockaddr *addr);
   3837 
   3838 
   3839 /**
   3840  * The data for the #MHD_EarlyUriLogCallback
   3841  */
   3842 struct MHD_EarlyUriCbData
   3843 {
   3844   /**
   3845    * The request handle.
   3846    * Headers are not yet available.
   3847    */
   3848   struct MHD_Request *request;
   3849 
   3850   /**
   3851    * The full URI ("request target") from the HTTP request, including URI
   3852    * parameters (the part after '?')
   3853    */
   3854   struct MHD_String full_uri;
   3855 
   3856   /**
   3857    * The request HTTP method
   3858    */
   3859   enum MHD_HTTP_Method method;
   3860 };
   3861 
   3862 /**
   3863  * Function called by MHD to allow the application to log the @a full_uri
   3864  * of the new request.
   3865  * This is the only moment when unmodified URI is provided.
   3866  * After this callback MHD parses the URI and modifies it by extracting
   3867  * GET parameters in-place.
   3868  *
   3869  * If this callback is set then it is the first application function called
   3870  * for the new request.
   3871  *
   3872  * If #MHD_RequestEndedCallback is also set then it is guaranteed that
   3873  * #MHD_RequestEndedCallback is called for the same request. Application
   3874  * may allocate request specific data in this callback and de-allocate
   3875  * the data in #MHD_RequestEndedCallback.
   3876  *
   3877  * @param cls client-defined closure
   3878  * @param req_data the request data
   3879  * @param request_app_context_ptr the pointer to variable that can be set to
   3880  *                                the application context for the request;
   3881  *                                initially the variable set to NULL
   3882  */
   3883 typedef void
   3884 (MHD_FN_PAR_NONNULL_ALL_ MHD_FN_PAR_INOUT_ (3)
   3885  *MHD_EarlyUriLogCallback)(void *cls,
   3886                            const struct MHD_EarlyUriCbData *req_data,
   3887                            void **request_app_context_ptr);
   3888 
   3889 
   3890 /**
   3891  * The `enum MHD_ConnectionNotificationCode` specifies types
   3892  * of connection notifications.
   3893  * @ingroup request
   3894  */
   3895 enum MHD_FIXED_ENUM_MHD_SET_ MHD_ConnectionNotificationCode
   3896 {
   3897 
   3898   /**
   3899    * A new connection has been started.
   3900    * @ingroup request
   3901    */
   3902   MHD_CONNECTION_NOTIFY_STARTED = 0
   3903   ,
   3904   /**
   3905    * A connection is closed.
   3906    * @ingroup request
   3907    */
   3908   MHD_CONNECTION_NOTIFY_CLOSED = 1
   3909 
   3910 };
   3911 
   3912 /**
   3913  * Extra details for connection notifications.
   3914  * Currently not used
   3915  */
   3916 union MHD_ConnectionNotificationDetails
   3917 {
   3918   /**
   3919    * Unused
   3920    */
   3921   int reserved1;
   3922 };
   3923 
   3924 
   3925 /**
   3926  * The connection notification data structure
   3927  */
   3928 struct MHD_ConnectionNotificationData
   3929 {
   3930   /**
   3931    * The connection handle
   3932    */
   3933   struct MHD_Connection *connection;
   3934   /**
   3935    * The connection-specific application context data (opaque for MHD).
   3936    * Initially set to NULL (for connections added by MHD) or set by
   3937    * @a connection_cntx parameter for connections added by
   3938    * #MHD_daemon_add_connection().
   3939    */
   3940   void *application_context;
   3941   /**
   3942    * The code of the event
   3943    */
   3944   enum MHD_ConnectionNotificationCode code;
   3945   /**
   3946    * Event details
   3947    */
   3948   union MHD_ConnectionNotificationDetails details;
   3949 };
   3950 
   3951 
   3952 /**
   3953  * Signature of the callback used by MHD to notify the
   3954  * application about started/stopped network connections
   3955  *
   3956  * @param cls client-defined closure
   3957  * @param[in,out]  data the details about the event
   3958  * @see #MHD_D_OPTION_NOTIFY_CONNECTION()
   3959  * @ingroup request
   3960  */
   3961 typedef void
   3962 (MHD_FN_PAR_NONNULL_ (2)
   3963  *MHD_NotifyConnectionCallback)(void *cls,
   3964                                 struct MHD_ConnectionNotificationData *data);
   3965 
   3966 
   3967 /**
   3968  * The type of stream notifications.
   3969  * @ingroup request
   3970  */
   3971 enum MHD_FIXED_ENUM_MHD_SET_ MHD_StreamNotificationCode
   3972 {
   3973   /**
   3974    * A new stream has been started.
   3975    * @ingroup request
   3976    */
   3977   MHD_STREAM_NOTIFY_STARTED = 0
   3978   ,
   3979   /**
   3980    * A stream is closed.
   3981    * @ingroup request
   3982    */
   3983   MHD_STREAM_NOTIFY_CLOSED = 1
   3984 };
   3985 
   3986 /**
   3987  * Additional information about stream started event
   3988  */
   3989 struct MHD_StreamNotificationDetailStarted
   3990 {
   3991   /**
   3992    * Set to #MHD_YES of the stream was started by client
   3993    */
   3994   enum MHD_Bool by_client;
   3995 };
   3996 
   3997 /**
   3998  * Additional information about stream events
   3999  */
   4000 union MHD_StreamNotificationDetail
   4001 {
   4002   /**
   4003    * Information for event #MHD_STREAM_NOTIFY_STARTED
   4004    */
   4005   struct MHD_StreamNotificationDetailStarted started;
   4006 };
   4007 
   4008 /**
   4009  * Stream notification data structure
   4010  */
   4011 struct MHD_StreamNotificationData
   4012 {
   4013   /**
   4014    * The handle of the stream
   4015    */
   4016   struct MHD_Stream *stream;
   4017   /**
   4018    * The code of the event
   4019    */
   4020   enum MHD_StreamNotificationCode code;
   4021   /**
   4022    * Detailed information about notification event
   4023    */
   4024   union MHD_StreamNotificationDetail details;
   4025 };
   4026 
   4027 
   4028 /**
   4029  * Signature of the callback used by MHD to notify the
   4030  * application about started/stopped data stream
   4031  * For HTTP/1.1 it is the same like network connection
   4032  * with 1:1 match.
   4033  *
   4034  * @param cls client-defined closure
   4035  * @param data the details about the event
   4036  * @see #MHD_D_OPTION_NOTIFY_STREAM()
   4037  * @ingroup request
   4038  */
   4039 typedef void
   4040 (MHD_FN_PAR_NONNULL_ (2)
   4041  *MHD_NotifyStreamCallback)(
   4042   void *cls,
   4043   const struct MHD_StreamNotificationData *data);
   4044 
   4045 #include "microhttpd2_generated_daemon_options.h"
   4046 
   4047 
   4048 /**
   4049  * The `enum MHD_RequestEndedCode` specifies reasons
   4050  * why a request has been ended.
   4051  * @ingroup request
   4052  */
   4053 enum MHD_FIXED_ENUM_MHD_SET_ MHD_RequestEndedCode
   4054 {
   4055 
   4056   /**
   4057    * The response was successfully sent.
   4058    * @ingroup request
   4059    */
   4060   MHD_REQUEST_ENDED_COMPLETED_OK = 0
   4061   ,
   4062   /**
   4063    * The response was successfully sent and connection is being switched
   4064    * to another protocol.
   4065    * @ingroup request
   4066    */
   4067   MHD_REQUEST_ENDED_COMPLETED_OK_UPGRADE = 1
   4068   ,
   4069   /**
   4070    * No activity on the connection for the number of seconds specified using
   4071    * #MHD_C_OPTION_TIMEOUT().
   4072    * @ingroup request
   4073    */
   4074   MHD_REQUEST_ENDED_TIMEOUT_REACHED = 10
   4075   ,
   4076   /**
   4077    * The connection was broken or TLS protocol error.
   4078    * @ingroup request
   4079    */
   4080   MHD_REQUEST_ENDED_CONNECTION_ERROR = 20
   4081   ,
   4082   /**
   4083    * The client terminated the connection by closing the socket either
   4084    * completely or for writing (TCP half-closed) before sending complete
   4085    * request.
   4086    * @ingroup request
   4087    */
   4088   MHD_REQUEST_ENDED_CLIENT_ABORT = 30
   4089   ,
   4090   /**
   4091    * The request is not valid according to HTTP specifications.
   4092    * @ingroup request
   4093    */
   4094   MHD_REQUEST_ENDED_HTTP_PROTOCOL_ERROR = 31
   4095   ,
   4096   /**
   4097    * The application aborted request without response.
   4098    * @ingroup request
   4099    */
   4100   MHD_REQUEST_ENDED_BY_APP_ABORT = 40
   4101   ,
   4102   /**
   4103    * The request was aborted due to the application failed to provide a valid
   4104    * response.
   4105    * @ingroup request
   4106    */
   4107   MHD_REQUEST_ENDED_BY_APP_ERROR = 41
   4108   ,
   4109   /**
   4110    * The request was aborted due to the application failed to register external
   4111    * event monitoring for the connection.
   4112    * @ingroup request
   4113    */
   4114   MHD_REQUEST_ENDED_BY_EXT_EVENT_ERROR = 42
   4115   ,
   4116   /**
   4117    * Error handling the connection due to resources exhausted.
   4118    * @ingroup request
   4119    */
   4120   MHD_REQUEST_ENDED_NO_RESOURCES = 50
   4121   ,
   4122   /**
   4123    * The request was aborted due to error reading file for file-backed response
   4124    * @ingroup request
   4125    */
   4126   MHD_REQUEST_ENDED_FILE_ERROR = 51
   4127   ,
   4128   /**
   4129    * The request was aborted due to error generating valid nonce for Digest Auth
   4130    * @ingroup request
   4131    */
   4132   MHD_REQUEST_ENDED_NONCE_ERROR = 52
   4133   ,
   4134   /**
   4135    * Closing the session since MHD is being shut down.
   4136    * @ingroup request
   4137    */
   4138   MHD_REQUEST_ENDED_DAEMON_SHUTDOWN = 60
   4139 };
   4140 
   4141 /**
   4142  * Additional information about request ending
   4143  */
   4144 union MHD_RequestEndedDetail
   4145 {
   4146   /**
   4147    * Reserved member.
   4148    * Do not use.
   4149    */
   4150   void *reserved;
   4151 };
   4152 
   4153 /**
   4154  * Request termination data structure
   4155  */
   4156 struct MHD_RequestEndedData
   4157 {
   4158   /**
   4159    * The request handle.
   4160    * Note that most of the request data may be already unvailable.
   4161    */
   4162   struct MHD_Request *req;
   4163   /**
   4164    * The code of the event
   4165    */
   4166   enum MHD_RequestEndedCode code;
   4167   /**
   4168    * Detailed information about the event
   4169    */
   4170   union MHD_RequestEndedDetail details;
   4171 };
   4172 
   4173 
   4174 /**
   4175  * Signature of the callback used by MHD to notify the application
   4176  * about completed requests.
   4177  *
   4178  * This is the last callback called for any request (if provided by
   4179  * the application).
   4180  *
   4181  * @param cls client-defined closure
   4182  * @param data the details about the event
   4183  * @param request_app_context the application request context, as possibly set
   4184                               by the #MHD_EarlyUriLogCallback
   4185  * @see #MHD_R_OPTION_TERMINATION_CALLBACK()
   4186  * @ingroup request
   4187  */
   4188 typedef void
   4189 (*MHD_RequestEndedCallback) (void *cls,
   4190                              const struct MHD_RequestEndedData *data,
   4191                              void *request_app_context);
   4192 
   4193 
   4194 #include "microhttpd2_generated_response_options.h"