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