diff options
Diffstat (limited to 'src/include/microhttpd.h')
-rw-r--r-- | src/include/microhttpd.h | 166 |
1 files changed, 103 insertions, 63 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index c6828aa9..96dc2f27 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -42,7 +42,7 @@ | |||
42 | * | 42 | * |
43 | * MHD understands POST data and is able to decode certain formats | 43 | * MHD understands POST data and is able to decode certain formats |
44 | * (at the moment only "application/x-www-form-urlencoded" and | 44 | * (at the moment only "application/x-www-form-urlencoded" and |
45 | * "mulitpart/formdata"). Unsupported encodings and large POST | 45 | * "mulitpart/formdata"). Unsupported encodings and large POST |
46 | * submissions may require the application to manually process | 46 | * submissions may require the application to manually process |
47 | * the stream, which is provided to the main application (and thus can be | 47 | * the stream, which is provided to the main application (and thus can be |
48 | * processed, just not conveniently by MHD). | 48 | * processed, just not conveniently by MHD). |
@@ -99,7 +99,7 @@ extern "C" | |||
99 | hence works on any platform, we use "standard" includes here | 99 | hence works on any platform, we use "standard" includes here |
100 | to build out-of-the-box for beginning users on common systems. | 100 | to build out-of-the-box for beginning users on common systems. |
101 | 101 | ||
102 | Once you have a proper build system and go for more exotic | 102 | Once you have a proper build system and go for more exotic |
103 | platforms, you should define MHD_PLATFORM_H in some header that | 103 | platforms, you should define MHD_PLATFORM_H in some header that |
104 | you always include *before* "microhttpd.h". Then the following | 104 | you always include *before* "microhttpd.h". Then the following |
105 | "standard" includes won't be used (which might be a good | 105 | "standard" includes won't be used (which might be a good |
@@ -121,7 +121,7 @@ extern "C" | |||
121 | * Current version of the library. | 121 | * Current version of the library. |
122 | * 0x01093001 = 1.9.30-1. | 122 | * 0x01093001 = 1.9.30-1. |
123 | */ | 123 | */ |
124 | #define MHD_VERSION 0x00093100 | 124 | #define MHD_VERSION 0x00093101 |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * MHD-internal return code for "YES". | 127 | * MHD-internal return code for "YES". |
@@ -254,7 +254,7 @@ extern "C" | |||
254 | * SHOUTcast. This will cause the response to begin | 254 | * SHOUTcast. This will cause the response to begin |
255 | * with the SHOUTcast "ICY" line instad of "HTTP". | 255 | * with the SHOUTcast "ICY" line instad of "HTTP". |
256 | * @ingroup specialized | 256 | * @ingroup specialized |
257 | */ | 257 | */ |
258 | #define MHD_ICY_FLAG ((uint32_t)(1 << 31)) | 258 | #define MHD_ICY_FLAG ((uint32_t)(1 << 31)) |
259 | 259 | ||
260 | /** | 260 | /** |
@@ -319,7 +319,7 @@ extern "C" | |||
319 | /** @} */ /* end of group headers */ | 319 | /** @} */ /* end of group headers */ |
320 | 320 | ||
321 | /** | 321 | /** |
322 | * @defgroup versions HTTP versions | 322 | * @defgroup versions HTTP versions |
323 | * These strings should be used to match against the first line of the | 323 | * These strings should be used to match against the first line of the |
324 | * HTTP header. | 324 | * HTTP header. |
325 | * @{ | 325 | * @{ |
@@ -367,7 +367,7 @@ struct MHD_Daemon; | |||
367 | * | 367 | * |
368 | * With HTTP/1.1, multiple requests can be run over the same | 368 | * With HTTP/1.1, multiple requests can be run over the same |
369 | * connection. However, MHD will only show one request per TCP | 369 | * connection. However, MHD will only show one request per TCP |
370 | * connection to the client at any given time. | 370 | * connection to the client at any given time. |
371 | * @ingroup request | 371 | * @ingroup request |
372 | */ | 372 | */ |
373 | struct MHD_Connection; | 373 | struct MHD_Connection; |
@@ -386,7 +386,7 @@ struct MHD_PostProcessor; | |||
386 | 386 | ||
387 | 387 | ||
388 | /** | 388 | /** |
389 | * @brief Flags for the `struct MHD_Daemon`. | 389 | * @brief Flags for the `struct MHD_Daemon`. |
390 | * | 390 | * |
391 | * Note that if neither #MHD_USE_THREAD_PER_CONNECTION nor | 391 | * Note that if neither #MHD_USE_THREAD_PER_CONNECTION nor |
392 | * #MHD_USE_SELECT_INTERNALLY is used, the client wants control over | 392 | * #MHD_USE_SELECT_INTERNALLY is used, the client wants control over |
@@ -476,7 +476,7 @@ enum MHD_FLAG | |||
476 | MHD_USE_NO_LISTEN_SOCKET = 256, | 476 | MHD_USE_NO_LISTEN_SOCKET = 256, |
477 | 477 | ||
478 | /** | 478 | /** |
479 | * Use `epoll()` instead of `select()` or `poll()` for the event loop. | 479 | * Use `epoll()` instead of `select()` or `poll()` for the event loop. |
480 | * This option is only available on Linux; using the option on | 480 | * This option is only available on Linux; using the option on |
481 | * non-Linux systems will cause #MHD_start_daemon to fail. | 481 | * non-Linux systems will cause #MHD_start_daemon to fail. |
482 | */ | 482 | */ |
@@ -611,9 +611,9 @@ enum MHD_OPTION | |||
611 | * parsing will no longer contain the options, which maybe inconvenient for | 611 | * parsing will no longer contain the options, which maybe inconvenient for |
612 | * logging. This option should be followed by two arguments, the first | 612 | * logging. This option should be followed by two arguments, the first |
613 | * one must be of the form | 613 | * one must be of the form |
614 | * | 614 | * |
615 | * void * my_logger(void *cls, const char *uri, struct MHD_Connection *con) | 615 | * void * my_logger(void *cls, const char *uri, struct MHD_Connection *con) |
616 | * | 616 | * |
617 | * where the return value will be passed as | 617 | * where the return value will be passed as |
618 | * (`* con_cls`) in calls to the #MHD_AccessHandlerCallback | 618 | * (`* con_cls`) in calls to the #MHD_AccessHandlerCallback |
619 | * when this request is processed later; returning a | 619 | * when this request is processed later; returning a |
@@ -675,7 +675,7 @@ enum MHD_OPTION | |||
675 | * a function of type #MHD_LogCallback and the second a pointer | 675 | * a function of type #MHD_LogCallback and the second a pointer |
676 | * `void *` which will be passed as the first argument to the log | 676 | * `void *` which will be passed as the first argument to the log |
677 | * callback. | 677 | * callback. |
678 | * | 678 | * |
679 | * Note that MHD will not generate any log messages | 679 | * Note that MHD will not generate any log messages |
680 | * if it was compiled without the "--enable-messages" | 680 | * if it was compiled without the "--enable-messages" |
681 | * flag being set. | 681 | * flag being set. |
@@ -696,7 +696,7 @@ enum MHD_OPTION | |||
696 | * Additional options given in an array of `struct MHD_OptionItem`. | 696 | * Additional options given in an array of `struct MHD_OptionItem`. |
697 | * The array must be terminated with an entry `{MHD_OPTION_END, 0, NULL}`. | 697 | * The array must be terminated with an entry `{MHD_OPTION_END, 0, NULL}`. |
698 | * An example for code using #MHD_OPTION_ARRAY is: | 698 | * An example for code using #MHD_OPTION_ARRAY is: |
699 | * | 699 | * |
700 | * struct MHD_OptionItem ops[] = { | 700 | * struct MHD_OptionItem ops[] = { |
701 | * { MHD_OPTION_CONNECTION_LIMIT, 100, NULL }, | 701 | * { MHD_OPTION_CONNECTION_LIMIT, 100, NULL }, |
702 | * { MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL }, | 702 | * { MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL }, |
@@ -705,7 +705,7 @@ enum MHD_OPTION | |||
705 | * d = MHD_start_daemon (0, 8080, NULL, NULL, dh, NULL, | 705 | * d = MHD_start_daemon (0, 8080, NULL, NULL, dh, NULL, |
706 | * MHD_OPTION_ARRAY, ops, | 706 | * MHD_OPTION_ARRAY, ops, |
707 | * MHD_OPTION_END); | 707 | * MHD_OPTION_END); |
708 | * | 708 | * |
709 | * For options that expect a single pointer argument, the | 709 | * For options that expect a single pointer argument, the |
710 | * second member of the `struct MHD_OptionItem` is ignored. | 710 | * second member of the `struct MHD_OptionItem` is ignored. |
711 | * For options that expect two pointer arguments, the first | 711 | * For options that expect two pointer arguments, the first |
@@ -721,7 +721,7 @@ enum MHD_OPTION | |||
721 | * decodes escape sequences of the form "%HH". This option should | 721 | * decodes escape sequences of the form "%HH". This option should |
722 | * be followed by two arguments, the first one must be of the form | 722 | * be followed by two arguments, the first one must be of the form |
723 | * | 723 | * |
724 | * size_t my_unescaper(void *cls, | 724 | * size_t my_unescaper(void *cls, |
725 | * struct MHD_Connection *c, | 725 | * struct MHD_Connection *c, |
726 | * char *s) | 726 | * char *s) |
727 | * | 727 | * |
@@ -737,7 +737,7 @@ enum MHD_OPTION | |||
737 | * Memory pointer for the random values to be used by the Digest | 737 | * Memory pointer for the random values to be used by the Digest |
738 | * Auth module. This option should be followed by two arguments. | 738 | * Auth module. This option should be followed by two arguments. |
739 | * First an integer of type `size_t` which specifies the size | 739 | * First an integer of type `size_t` which specifies the size |
740 | * of the buffer pointed to by the second argument in bytes. | 740 | * of the buffer pointed to by the second argument in bytes. |
741 | * Note that the application must ensure that the buffer of the | 741 | * Note that the application must ensure that the buffer of the |
742 | * second argument remains allocated and unmodified while the | 742 | * second argument remains allocated and unmodified while the |
743 | * deamon is running. | 743 | * deamon is running. |
@@ -919,7 +919,7 @@ union MHD_ConnectionInfo | |||
919 | int /* enum gnutls_protocol */ protocol; | 919 | int /* enum gnutls_protocol */ protocol; |
920 | 920 | ||
921 | /** | 921 | /** |
922 | * Connect socket | 922 | * Connect socket |
923 | */ | 923 | */ |
924 | int connect_fd; | 924 | int connect_fd; |
925 | 925 | ||
@@ -1046,7 +1046,7 @@ enum MHD_DaemonInfoType | |||
1046 | * @param reason error detail, may be NULL | 1046 | * @param reason error detail, may be NULL |
1047 | * @ingroup logging | 1047 | * @ingroup logging |
1048 | */ | 1048 | */ |
1049 | typedef | 1049 | typedef |
1050 | void (*MHD_PanicCallback) (void *cls, | 1050 | void (*MHD_PanicCallback) (void *cls, |
1051 | const char *file, | 1051 | const char *file, |
1052 | unsigned int line, | 1052 | unsigned int line, |
@@ -1076,7 +1076,7 @@ typedef int | |||
1076 | * @param cls argument given together with the function | 1076 | * @param cls argument given together with the function |
1077 | * pointer when the handler was registered with MHD | 1077 | * pointer when the handler was registered with MHD |
1078 | * @param url the requested url | 1078 | * @param url the requested url |
1079 | * @param method the HTTP method used (#MHD_HTTP_METHOD_GET, | 1079 | * @param method the HTTP method used (#MHD_HTTP_METHOD_GET, |
1080 | * #MHD_HTTP_METHOD_PUT, etc.) | 1080 | * #MHD_HTTP_METHOD_PUT, etc.) |
1081 | * @param version the HTTP version string (i.e. | 1081 | * @param version the HTTP version string (i.e. |
1082 | * #MHD_HTTP_VERSION_1_1) | 1082 | * #MHD_HTTP_VERSION_1_1) |
@@ -1157,12 +1157,9 @@ typedef int | |||
1157 | * total number of bytes that has been placed into @a buf should be | 1157 | * total number of bytes that has been placed into @a buf should be |
1158 | * returned. | 1158 | * returned. |
1159 | * | 1159 | * |
1160 | * Note that returning zero will cause libmicrohttpd to try again, | 1160 | * Note that returning zero will cause libmicrohttpd to try again. |
1161 | * either "immediately" if in multi-threaded mode (in which case the | 1161 | * Thus, returning zero should only be used in conjunction |
1162 | * callback may want to do blocking operations) or in the next round | 1162 | * with MHD_suspend_connection() to avoid busy waiting. |
1163 | * if #MHD_run is used. Returning 0 for a daemon that runs in internal | ||
1164 | * select mode is an error (since it would result in busy waiting) and | ||
1165 | * will cause the program to be aborted (via `abort()`). | ||
1166 | * | 1163 | * |
1167 | * @param cls extra argument to the callback | 1164 | * @param cls extra argument to the callback |
1168 | * @param pos position in the datastream to access; | 1165 | * @param pos position in the datastream to access; |
@@ -1175,7 +1172,7 @@ typedef int | |||
1175 | * obtained from the content reader so far. | 1172 | * obtained from the content reader so far. |
1176 | * @param buf where to copy the data | 1173 | * @param buf where to copy the data |
1177 | * @param max maximum number of bytes to copy to @a buf (size of @a buf) | 1174 | * @param max maximum number of bytes to copy to @a buf (size of @a buf) |
1178 | * @return number of bytes written to @a buf; | 1175 | * @return number of bytes written to @a buf; |
1179 | * 0 is legal unless we are running in internal select mode (since | 1176 | * 0 is legal unless we are running in internal select mode (since |
1180 | * this would cause busy-waiting); 0 in external select mode | 1177 | * this would cause busy-waiting); 0 in external select mode |
1181 | * will cause this function to be called again once the external | 1178 | * will cause this function to be called again once the external |
@@ -1183,7 +1180,7 @@ typedef int | |||
1183 | * #MHD_CONTENT_READER_END_OF_STREAM (-1) for the regular | 1180 | * #MHD_CONTENT_READER_END_OF_STREAM (-1) for the regular |
1184 | * end of transmission (with chunked encoding, MHD will then | 1181 | * end of transmission (with chunked encoding, MHD will then |
1185 | * terminate the chunk and send any HTTP footers that might be | 1182 | * terminate the chunk and send any HTTP footers that might be |
1186 | * present; without chunked encoding and given an unknown | 1183 | * present; without chunked encoding and given an unknown |
1187 | * response size, MHD will simply close the connection; note | 1184 | * response size, MHD will simply close the connection; note |
1188 | * that while returning #MHD_CONTENT_READER_END_OF_STREAM is not technically | 1185 | * that while returning #MHD_CONTENT_READER_END_OF_STREAM is not technically |
1189 | * legal if a response size was specified, MHD accepts this | 1186 | * legal if a response size was specified, MHD accepts this |
@@ -1214,7 +1211,7 @@ typedef ssize_t | |||
1214 | * @param cls closure | 1211 | * @param cls closure |
1215 | * @ingroup response | 1212 | * @ingroup response |
1216 | */ | 1213 | */ |
1217 | typedef void | 1214 | typedef void |
1218 | (*MHD_ContentReaderFreeCallback) (void *cls); | 1215 | (*MHD_ContentReaderFreeCallback) (void *cls); |
1219 | 1216 | ||
1220 | 1217 | ||
@@ -1244,8 +1241,8 @@ typedef int | |||
1244 | const char *filename, | 1241 | const char *filename, |
1245 | const char *content_type, | 1242 | const char *content_type, |
1246 | const char *transfer_encoding, | 1243 | const char *transfer_encoding, |
1247 | const char *data, | 1244 | const char *data, |
1248 | uint64_t off, | 1245 | uint64_t off, |
1249 | size_t size); | 1246 | size_t size); |
1250 | 1247 | ||
1251 | /* **************** Daemon handling functions ***************** */ | 1248 | /* **************** Daemon handling functions ***************** */ |
@@ -1271,7 +1268,7 @@ struct MHD_Daemon * | |||
1271 | MHD_start_daemon_va (unsigned int flags, | 1268 | MHD_start_daemon_va (unsigned int flags, |
1272 | uint16_t port, | 1269 | uint16_t port, |
1273 | MHD_AcceptPolicyCallback apc, void *apc_cls, | 1270 | MHD_AcceptPolicyCallback apc, void *apc_cls, |
1274 | MHD_AccessHandlerCallback dh, void *dh_cls, | 1271 | MHD_AccessHandlerCallback dh, void *dh_cls, |
1275 | va_list ap); | 1272 | va_list ap); |
1276 | 1273 | ||
1277 | 1274 | ||
@@ -1295,7 +1292,7 @@ struct MHD_Daemon * | |||
1295 | MHD_start_daemon (unsigned int flags, | 1292 | MHD_start_daemon (unsigned int flags, |
1296 | uint16_t port, | 1293 | uint16_t port, |
1297 | MHD_AcceptPolicyCallback apc, void *apc_cls, | 1294 | MHD_AcceptPolicyCallback apc, void *apc_cls, |
1298 | MHD_AccessHandlerCallback dh, void *dh_cls, | 1295 | MHD_AccessHandlerCallback dh, void *dh_cls, |
1299 | ...); | 1296 | ...); |
1300 | 1297 | ||
1301 | 1298 | ||
@@ -1314,7 +1311,7 @@ MHD_start_daemon (unsigned int flags, | |||
1314 | * #MHD_start_daemon, this function will return -1. | 1311 | * #MHD_start_daemon, this function will return -1. |
1315 | * | 1312 | * |
1316 | * @param daemon daemon to stop accepting new connections for | 1313 | * @param daemon daemon to stop accepting new connections for |
1317 | * @return old listen socket on success, -1 if the daemon was | 1314 | * @return old listen socket on success, -1 if the daemon was |
1318 | * already not listening anymore | 1315 | * already not listening anymore |
1319 | * @ingroup specialized | 1316 | * @ingroup specialized |
1320 | */ | 1317 | */ |
@@ -1328,7 +1325,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon); | |||
1328 | * @param daemon daemon to stop | 1325 | * @param daemon daemon to stop |
1329 | * @ingroup event | 1326 | * @ingroup event |
1330 | */ | 1327 | */ |
1331 | void | 1328 | void |
1332 | MHD_stop_daemon (struct MHD_Daemon *daemon); | 1329 | MHD_stop_daemon (struct MHD_Daemon *daemon); |
1333 | 1330 | ||
1334 | 1331 | ||
@@ -1361,8 +1358,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon); | |||
1361 | * set to indicate further details about the error. | 1358 | * set to indicate further details about the error. |
1362 | * @ingroup specialized | 1359 | * @ingroup specialized |
1363 | */ | 1360 | */ |
1364 | int | 1361 | int |
1365 | MHD_add_connection (struct MHD_Daemon *daemon, | 1362 | MHD_add_connection (struct MHD_Daemon *daemon, |
1366 | int client_socket, | 1363 | int client_socket, |
1367 | const struct sockaddr *addr, | 1364 | const struct sockaddr *addr, |
1368 | socklen_t addrlen); | 1365 | socklen_t addrlen); |
@@ -1385,8 +1382,8 @@ MHD_add_connection (struct MHD_Daemon *daemon, | |||
1385 | int | 1382 | int |
1386 | MHD_get_fdset (struct MHD_Daemon *daemon, | 1383 | MHD_get_fdset (struct MHD_Daemon *daemon, |
1387 | fd_set *read_fd_set, | 1384 | fd_set *read_fd_set, |
1388 | fd_set *write_fd_set, | 1385 | fd_set *write_fd_set, |
1389 | fd_set *except_fd_set, | 1386 | fd_set *except_fd_set, |
1390 | int *max_fd); | 1387 | int *max_fd); |
1391 | 1388 | ||
1392 | 1389 | ||
@@ -1404,8 +1401,8 @@ MHD_get_fdset (struct MHD_Daemon *daemon, | |||
1404 | * necessiate the use of a timeout right now). | 1401 | * necessiate the use of a timeout right now). |
1405 | * @ingroup event | 1402 | * @ingroup event |
1406 | */ | 1403 | */ |
1407 | int | 1404 | int |
1408 | MHD_get_timeout (struct MHD_Daemon *daemon, | 1405 | MHD_get_timeout (struct MHD_Daemon *daemon, |
1409 | MHD_UNSIGNED_LONG_LONG *timeout); | 1406 | MHD_UNSIGNED_LONG_LONG *timeout); |
1410 | 1407 | ||
1411 | 1408 | ||
@@ -1428,7 +1425,7 @@ MHD_get_timeout (struct MHD_Daemon *daemon, | |||
1428 | * options for this call. | 1425 | * options for this call. |
1429 | * @ingroup event | 1426 | * @ingroup event |
1430 | */ | 1427 | */ |
1431 | int | 1428 | int |
1432 | MHD_run (struct MHD_Daemon *daemon); | 1429 | MHD_run (struct MHD_Daemon *daemon); |
1433 | 1430 | ||
1434 | 1431 | ||
@@ -1452,7 +1449,7 @@ MHD_run (struct MHD_Daemon *daemon); | |||
1452 | * @ingroup event | 1449 | * @ingroup event |
1453 | */ | 1450 | */ |
1454 | int | 1451 | int |
1455 | MHD_run_from_select (struct MHD_Daemon *daemon, | 1452 | MHD_run_from_select (struct MHD_Daemon *daemon, |
1456 | const fd_set *read_fd_set, | 1453 | const fd_set *read_fd_set, |
1457 | const fd_set *write_fd_set, | 1454 | const fd_set *write_fd_set, |
1458 | const fd_set *except_fd_set); | 1455 | const fd_set *except_fd_set); |
@@ -1486,7 +1483,7 @@ MHD_get_connection_values (struct MHD_Connection *connection, | |||
1486 | * them). This maybe required in certain situations (see Mantis | 1483 | * them). This maybe required in certain situations (see Mantis |
1487 | * #1399) where (broken) HTTP implementations fail to supply values | 1484 | * #1399) where (broken) HTTP implementations fail to supply values |
1488 | * needed by the post processor (or other parts of the application). | 1485 | * needed by the post processor (or other parts of the application). |
1489 | * | 1486 | * |
1490 | * This function MUST only be called from within the | 1487 | * This function MUST only be called from within the |
1491 | * #MHD_AccessHandlerCallback (otherwise, access maybe improperly | 1488 | * #MHD_AccessHandlerCallback (otherwise, access maybe improperly |
1492 | * synchronized). Furthermore, the client must guarantee that the key | 1489 | * synchronized). Furthermore, the client must guarantee that the key |
@@ -1507,7 +1504,7 @@ MHD_get_connection_values (struct MHD_Connection *connection, | |||
1507 | int | 1504 | int |
1508 | MHD_set_connection_value (struct MHD_Connection *connection, | 1505 | MHD_set_connection_value (struct MHD_Connection *connection, |
1509 | enum MHD_ValueKind kind, | 1506 | enum MHD_ValueKind kind, |
1510 | const char *key, | 1507 | const char *key, |
1511 | const char *value); | 1508 | const char *value); |
1512 | 1509 | ||
1513 | 1510 | ||
@@ -1527,7 +1524,7 @@ MHD_set_connection_value (struct MHD_Connection *connection, | |||
1527 | * @param cls passed to @a cb | 1524 | * @param cls passed to @a cb |
1528 | * @ingroup logging | 1525 | * @ingroup logging |
1529 | */ | 1526 | */ |
1530 | void | 1527 | void |
1531 | MHD_set_panic_func (MHD_PanicCallback cb, void *cls); | 1528 | MHD_set_panic_func (MHD_PanicCallback cb, void *cls); |
1532 | 1529 | ||
1533 | 1530 | ||
@@ -1560,10 +1557,53 @@ MHD_lookup_connection_value (struct MHD_Connection *connection, | |||
1560 | */ | 1557 | */ |
1561 | int | 1558 | int |
1562 | MHD_queue_response (struct MHD_Connection *connection, | 1559 | MHD_queue_response (struct MHD_Connection *connection, |
1563 | unsigned int status_code, | 1560 | unsigned int status_code, |
1564 | struct MHD_Response *response); | 1561 | struct MHD_Response *response); |
1565 | 1562 | ||
1566 | 1563 | ||
1564 | /** | ||
1565 | * Suspend handling of network data for a given connection. This can | ||
1566 | * be used to dequeue a connection from MHD's event loop (external | ||
1567 | * select, internal select or thread pool; not applicable to | ||
1568 | * thread-per-connection!) for a while. | ||
1569 | * | ||
1570 | * If you use this API in conjunction with a internal select or a | ||
1571 | * thread pool, you must set the option #MHD_USE_PIPE_FOR_SHUTDOWN to | ||
1572 | * ensure that a resumed connection is immediately processed by MHD. | ||
1573 | * | ||
1574 | * Suspended connections continue to count against the total number of | ||
1575 | * connections allowed (per daemon, as well as per IP, if such limits | ||
1576 | * are set). Suspended connections will NOT time out; timeouts will | ||
1577 | * restart when the connection handling is resumed. While a | ||
1578 | * connection is suspended, MHD will not detect disconnects by the | ||
1579 | * client. | ||
1580 | * | ||
1581 | * The only safe time to suspend a connection is from the | ||
1582 | * #MHD_AccessHandlerCallback. | ||
1583 | * | ||
1584 | * Finally, it is an API violation to call #MHD_stop_daemon while | ||
1585 | * having suspended connections (this will at least create memory and | ||
1586 | * socket leaks or lead to undefined behavior). You must explicitly | ||
1587 | * resume all connections before stopping the daemon. | ||
1588 | * | ||
1589 | * @param connection the connection to suspend | ||
1590 | */ | ||
1591 | void | ||
1592 | MHD_suspend_connection (struct MHD_Connection *connection); | ||
1593 | |||
1594 | |||
1595 | /** | ||
1596 | * Resume handling of network data for suspended connection. It is | ||
1597 | * safe to resume a suspended connection at any time. Calling this | ||
1598 | * function on a connection that was not previously suspended will | ||
1599 | * result in undefined behavior. | ||
1600 | * | ||
1601 | * @param connection the connection to resume | ||
1602 | */ | ||
1603 | void | ||
1604 | MHD_resume_connection (struct MHD_Connection *connection); | ||
1605 | |||
1606 | |||
1567 | /* **************** Response manipulation functions ***************** */ | 1607 | /* **************** Response manipulation functions ***************** */ |
1568 | 1608 | ||
1569 | /** | 1609 | /** |
@@ -1615,7 +1655,7 @@ MHD_create_response_from_data (size_t size, | |||
1615 | * given for the response. | 1655 | * given for the response. |
1616 | * @ingroup response | 1656 | * @ingroup response |
1617 | */ | 1657 | */ |
1618 | enum MHD_ResponseMemoryMode | 1658 | enum MHD_ResponseMemoryMode |
1619 | { | 1659 | { |
1620 | 1660 | ||
1621 | /** | 1661 | /** |
@@ -1667,7 +1707,7 @@ MHD_create_response_from_buffer (size_t size, | |||
1667 | * header information and then be used any number of times. | 1707 | * header information and then be used any number of times. |
1668 | * | 1708 | * |
1669 | * @param size size of the data portion of the response | 1709 | * @param size size of the data portion of the response |
1670 | * @param fd file descriptor referring to a file on disk with the | 1710 | * @param fd file descriptor referring to a file on disk with the |
1671 | * data; will be closed when response is destroyed; | 1711 | * data; will be closed when response is destroyed; |
1672 | * fd should be in 'blocking' mode | 1712 | * fd should be in 'blocking' mode |
1673 | * @return NULL on error (i.e. invalid arguments, out of memory) | 1713 | * @return NULL on error (i.e. invalid arguments, out of memory) |
@@ -1687,7 +1727,7 @@ MHD_create_response_from_fd (size_t size, | |||
1687 | * data; will be closed when response is destroyed; | 1727 | * data; will be closed when response is destroyed; |
1688 | * fd should be in 'blocking' mode | 1728 | * fd should be in 'blocking' mode |
1689 | * @param offset offset to start reading from in the file; | 1729 | * @param offset offset to start reading from in the file; |
1690 | * Be careful! `off_t` may have been compiled to be a | 1730 | * Be careful! `off_t` may have been compiled to be a |
1691 | * 64-bit variable for MHD, in which case your application | 1731 | * 64-bit variable for MHD, in which case your application |
1692 | * also has to be compiled using the same options! Read | 1732 | * also has to be compiled using the same options! Read |
1693 | * the MHD manual for more details. | 1733 | * the MHD manual for more details. |
@@ -1705,7 +1745,7 @@ MHD_create_response_from_fd_at_offset (size_t size, | |||
1705 | * Bits in an event mask that specifies which actions | 1745 | * Bits in an event mask that specifies which actions |
1706 | * MHD should perform and under which conditions it | 1746 | * MHD should perform and under which conditions it |
1707 | * should call the 'upgrade' callback again. | 1747 | * should call the 'upgrade' callback again. |
1708 | */ | 1748 | */ |
1709 | enum MHD_UpgradeEventMask | 1749 | enum MHD_UpgradeEventMask |
1710 | { | 1750 | { |
1711 | 1751 | ||
@@ -1731,7 +1771,7 @@ enum MHD_UpgradeEventMask | |||
1731 | * Do not wait on any socket actions, we're waiting on | 1771 | * Do not wait on any socket actions, we're waiting on |
1732 | * an 'external' event. Run the function again once | 1772 | * an 'external' event. Run the function again once |
1733 | * the 'select' call returns _without_ this socket even | 1773 | * the 'select' call returns _without_ this socket even |
1734 | * being involved in the select sets (useful in | 1774 | * being involved in the select sets (useful in |
1735 | * conjunction with the external select loop). | 1775 | * conjunction with the external select loop). |
1736 | */ | 1776 | */ |
1737 | MHD_UPGRADE_EVENT_EXTERNAL = 4, | 1777 | MHD_UPGRADE_EVENT_EXTERNAL = 4, |
@@ -1743,15 +1783,15 @@ enum MHD_UpgradeEventMask | |||
1743 | * may ignore if the platform does not support it). Note that | 1783 | * may ignore if the platform does not support it). Note that |
1744 | * only returning 'CORK' will *also* cause the socket to be closed! | 1784 | * only returning 'CORK' will *also* cause the socket to be closed! |
1745 | */ | 1785 | */ |
1746 | MHD_UPGRADE_EVENT_CORK = 8 | 1786 | MHD_UPGRADE_EVENT_CORK = 8 |
1747 | 1787 | ||
1748 | }; | 1788 | }; |
1749 | 1789 | ||
1750 | 1790 | ||
1751 | /** | 1791 | /** |
1752 | * Function called after a protocol "upgrade" response was sent | 1792 | * Function called after a protocol "upgrade" response was sent |
1753 | * successfully and the socket should now be controlled by some | 1793 | * successfully and the socket should now be controlled by some |
1754 | * protocol other than HTTP. | 1794 | * protocol other than HTTP. |
1755 | * | 1795 | * |
1756 | * Any data received on the socket will be made available in | 1796 | * Any data received on the socket will be made available in |
1757 | * 'data_in'. The function should update 'data_in_size' to | 1797 | * 'data_in'. The function should update 'data_in_size' to |
@@ -1786,7 +1826,7 @@ enum MHD_UpgradeEventMask | |||
1786 | * be also given to the #MHD_RequestCompletedCallback | 1826 | * be also given to the #MHD_RequestCompletedCallback |
1787 | * @param data_in_size available data for reading, set to data read | 1827 | * @param data_in_size available data for reading, set to data read |
1788 | * @param data_in data read from the socket | 1828 | * @param data_in data read from the socket |
1789 | * @param data_out_size available buffer for writing, set to bytes | 1829 | * @param data_out_size available buffer for writing, set to bytes |
1790 | * written to 'data_out' | 1830 | * written to 'data_out' |
1791 | * @param data_out buffer for sending data via the connection | 1831 | * @param data_out buffer for sending data via the connection |
1792 | * @return desired actions for event handling loop | 1832 | * @return desired actions for event handling loop |
@@ -1843,7 +1883,7 @@ MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, | |||
1843 | * @param response response to destroy | 1883 | * @param response response to destroy |
1844 | * @ingroup response | 1884 | * @ingroup response |
1845 | */ | 1885 | */ |
1846 | void | 1886 | void |
1847 | MHD_destroy_response (struct MHD_Response *response); | 1887 | MHD_destroy_response (struct MHD_Response *response); |
1848 | 1888 | ||
1849 | 1889 | ||
@@ -1874,7 +1914,7 @@ MHD_add_response_header (struct MHD_Response *response, | |||
1874 | */ | 1914 | */ |
1875 | int | 1915 | int |
1876 | MHD_add_response_footer (struct MHD_Response *response, | 1916 | MHD_add_response_footer (struct MHD_Response *response, |
1877 | const char *footer, | 1917 | const char *footer, |
1878 | const char *content); | 1918 | const char *content); |
1879 | 1919 | ||
1880 | 1920 | ||
@@ -1889,7 +1929,7 @@ MHD_add_response_footer (struct MHD_Response *response, | |||
1889 | */ | 1929 | */ |
1890 | int | 1930 | int |
1891 | MHD_del_response_header (struct MHD_Response *response, | 1931 | MHD_del_response_header (struct MHD_Response *response, |
1892 | const char *header, | 1932 | const char *header, |
1893 | const char *content); | 1933 | const char *content); |
1894 | 1934 | ||
1895 | 1935 | ||
@@ -1982,7 +2022,7 @@ MHD_post_process (struct MHD_PostProcessor *pp, | |||
1982 | * value of this function | 2022 | * value of this function |
1983 | * @ingroup request | 2023 | * @ingroup request |
1984 | */ | 2024 | */ |
1985 | int | 2025 | int |
1986 | MHD_destroy_post_processor (struct MHD_PostProcessor *pp); | 2026 | MHD_destroy_post_processor (struct MHD_PostProcessor *pp); |
1987 | 2027 | ||
1988 | 2028 | ||
@@ -2098,7 +2138,7 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, | |||
2098 | */ | 2138 | */ |
2099 | const union MHD_ConnectionInfo * | 2139 | const union MHD_ConnectionInfo * |
2100 | MHD_get_connection_info (struct MHD_Connection *connection, | 2140 | MHD_get_connection_info (struct MHD_Connection *connection, |
2101 | enum MHD_ConnectionInfoType info_type, | 2141 | enum MHD_ConnectionInfoType info_type, |
2102 | ...); | 2142 | ...); |
2103 | 2143 | ||
2104 | 2144 | ||
@@ -2128,11 +2168,11 @@ enum MHD_CONNECTION_OPTION | |||
2128 | * @return #MHD_YES on success, #MHD_NO if setting the option failed | 2168 | * @return #MHD_YES on success, #MHD_NO if setting the option failed |
2129 | * @ingroup specialized | 2169 | * @ingroup specialized |
2130 | */ | 2170 | */ |
2131 | int | 2171 | int |
2132 | MHD_set_connection_option (struct MHD_Connection *connection, | 2172 | MHD_set_connection_option (struct MHD_Connection *connection, |
2133 | enum MHD_CONNECTION_OPTION option, | 2173 | enum MHD_CONNECTION_OPTION option, |
2134 | ...); | 2174 | ...); |
2135 | 2175 | ||
2136 | 2176 | ||
2137 | /** | 2177 | /** |
2138 | * Information about an MHD daemon. | 2178 | * Information about an MHD daemon. |
@@ -2171,7 +2211,7 @@ union MHD_DaemonInfo | |||
2171 | */ | 2211 | */ |
2172 | const union MHD_DaemonInfo * | 2212 | const union MHD_DaemonInfo * |
2173 | MHD_get_daemon_info (struct MHD_Daemon *daemon, | 2213 | MHD_get_daemon_info (struct MHD_Daemon *daemon, |
2174 | enum MHD_DaemonInfoType info_type, | 2214 | enum MHD_DaemonInfoType info_type, |
2175 | ...); | 2215 | ...); |
2176 | 2216 | ||
2177 | 2217 | ||
@@ -2181,7 +2221,7 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon, | |||
2181 | * @return static version string, e.g. "0.9.9" | 2221 | * @return static version string, e.g. "0.9.9" |
2182 | * @ingroup specialized | 2222 | * @ingroup specialized |
2183 | */ | 2223 | */ |
2184 | const char* | 2224 | const char* |
2185 | MHD_get_version (void); | 2225 | MHD_get_version (void); |
2186 | 2226 | ||
2187 | 2227 | ||