libmicrohttpd2

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

microhttpd2_preamble.h.in (139653B)


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