aboutsummaryrefslogtreecommitdiff
path: root/src/include/microhttpd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/microhttpd.h')
-rw-r--r--src/include/microhttpd.h215
1 files changed, 141 insertions, 74 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 3b88d39d..9e09652e 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -106,7 +106,7 @@ extern "C"
106/** 106/**
107 * Current version of the library. 107 * Current version of the library.
108 */ 108 */
109#define MHD_VERSION 0x00090D01 109#define MHD_VERSION 0x00090E00
110 110
111/** 111/**
112 * MHD-internal return code for "YES". 112 * MHD-internal return code for "YES".
@@ -368,9 +368,9 @@ enum MHD_FLAG
368 MHD_USE_POLL = 64 368 MHD_USE_POLL = 64
369}; 369};
370 370
371
371/** 372/**
372 * MHD options. Passed in the varargs portion 373 * MHD options. Passed in the varargs portion of MHD_start_daemon.
373 * of MHD_start_daemon.
374 */ 374 */
375enum MHD_OPTION 375enum MHD_OPTION
376{ 376{
@@ -662,6 +662,7 @@ enum MHD_ValueKind
662 MHD_FOOTER_KIND = 16 662 MHD_FOOTER_KIND = 16
663}; 663};
664 664
665
665/** 666/**
666 * The MHD_RequestTerminationCode specifies reasons 667 * The MHD_RequestTerminationCode specifies reasons
667 * why a request has been terminated (or completed). 668 * why a request has been terminated (or completed).
@@ -743,6 +744,7 @@ enum MHD_ConnectionInfoType
743 744
744}; 745};
745 746
747
746/** 748/**
747 * Values of this enum are used to specify what 749 * Values of this enum are used to specify what
748 * information about a deamon is desired. 750 * information about a deamon is desired.
@@ -773,7 +775,6 @@ enum MHD_DaemonInfoType
773}; 775};
774 776
775 777
776
777/** 778/**
778 * Handle for the daemon (listening on a socket for HTTP traffic). 779 * Handle for the daemon (listening on a socket for HTTP traffic).
779 */ 780 */
@@ -797,6 +798,7 @@ struct MHD_Response;
797 */ 798 */
798struct MHD_PostProcessor; 799struct MHD_PostProcessor;
799 800
801
800/** 802/**
801 * Callback for serious error condition. The default action is to abort(). 803 * Callback for serious error condition. The default action is to abort().
802 * @param cls user specified value 804 * @param cls user specified value
@@ -804,10 +806,11 @@ struct MHD_PostProcessor;
804 * @param line where the error occured 806 * @param line where the error occured
805 * @param reason error detail, may be NULL 807 * @param reason error detail, may be NULL
806 */ 808 */
807typedef void (*MHD_PanicCallback) (void *cls, 809typedef
808 const char *file, 810 void (*MHD_PanicCallback) (void *cls,
809 unsigned int line, 811 const char *file,
810 const char *reason); 812 unsigned int line,
813 const char *reason);
811 814
812/** 815/**
813 * Allow or deny a client to connect. 816 * Allow or deny a client to connect.
@@ -821,6 +824,7 @@ typedef int
821 const struct sockaddr * addr, 824 const struct sockaddr * addr,
822 socklen_t addrlen); 825 socklen_t addrlen);
823 826
827
824/** 828/**
825 * A client has requested the given url using the given method ("GET", 829 * A client has requested the given url using the given method ("GET",
826 * "PUT", "DELETE", "POST", etc). The callback must call MHS 830 * "PUT", "DELETE", "POST", etc). The callback must call MHS
@@ -866,6 +870,7 @@ typedef int
866 size_t *upload_data_size, 870 size_t *upload_data_size,
867 void **con_cls); 871 void **con_cls);
868 872
873
869/** 874/**
870 * Signature of the callback used by MHD to notify the 875 * Signature of the callback used by MHD to notify the
871 * application about completed requests. 876 * application about completed requests.
@@ -883,6 +888,7 @@ typedef void
883 void **con_cls, 888 void **con_cls,
884 enum MHD_RequestTerminationCode toe); 889 enum MHD_RequestTerminationCode toe);
885 890
891
886/** 892/**
887 * Iterator over key-value pairs. This iterator 893 * Iterator over key-value pairs. This iterator
888 * can be used to iterate over all of the cookies, 894 * can be used to iterate over all of the cookies,
@@ -898,6 +904,7 @@ typedef int
898 enum MHD_ValueKind kind, 904 enum MHD_ValueKind kind,
899 const char *key, const char *value); 905 const char *key, const char *value);
900 906
907
901/** 908/**
902 * Callback used by libmicrohttpd in order to obtain content. The 909 * Callback used by libmicrohttpd in order to obtain content. The
903 * callback is to copy at most "max" bytes of content into "buf". The 910 * callback is to copy at most "max" bytes of content into "buf". The
@@ -951,13 +958,16 @@ typedef ssize_t
951 char *buf, 958 char *buf,
952 size_t max); 959 size_t max);
953 960
961
954/** 962/**
955 * This method is called by libmicrohttpd if we 963 * This method is called by libmicrohttpd if we
956 * are done with a content reader. It should 964 * are done with a content reader. It should
957 * be used to free resources associated with the 965 * be used to free resources associated with the
958 * content reader. 966 * content reader.
959 */ 967 */
960typedef void (*MHD_ContentReaderFreeCallback) (void *cls); 968typedef void
969 (*MHD_ContentReaderFreeCallback) (void *cls);
970
961 971
962/** 972/**
963 * Iterator over key-value pairs where the value 973 * Iterator over key-value pairs where the value
@@ -985,7 +995,9 @@ typedef int
985 const char *filename, 995 const char *filename,
986 const char *content_type, 996 const char *content_type,
987 const char *transfer_encoding, 997 const char *transfer_encoding,
988 const char *data, uint64_t off, size_t size); 998 const char *data,
999 uint64_t off,
1000 size_t size);
989 1001
990/* **************** Daemon handling functions ***************** */ 1002/* **************** Daemon handling functions ***************** */
991 1003
@@ -1005,12 +1017,13 @@ typedef int
1005 * terminated with MHD_OPTION_END). 1017 * terminated with MHD_OPTION_END).
1006 * @return NULL on error, handle to daemon on success 1018 * @return NULL on error, handle to daemon on success
1007 */ 1019 */
1008struct MHD_Daemon *MHD_start_daemon_va (unsigned int options, 1020struct MHD_Daemon *
1009 uint16_t port, 1021MHD_start_daemon_va (unsigned int options,
1010 MHD_AcceptPolicyCallback apc, 1022 uint16_t port,
1011 void *apc_cls, 1023 MHD_AcceptPolicyCallback apc, void *apc_cls,
1012 MHD_AccessHandlerCallback dh, 1024 MHD_AccessHandlerCallback dh, void *dh_cls,
1013 void *dh_cls, va_list ap); 1025 va_list ap);
1026
1014 1027
1015/** 1028/**
1016 * Start a webserver on the given port. Variadic version of 1029 * Start a webserver on the given port. Variadic version of
@@ -1027,19 +1040,21 @@ struct MHD_Daemon *MHD_start_daemon_va (unsigned int options,
1027 * @param dh_cls extra argument to dh 1040 * @param dh_cls extra argument to dh
1028 * @return NULL on error, handle to daemon on success 1041 * @return NULL on error, handle to daemon on success
1029 */ 1042 */
1030struct MHD_Daemon *MHD_start_daemon (unsigned int flags, 1043struct MHD_Daemon *
1031 uint16_t port, 1044MHD_start_daemon (unsigned int flags,
1032 MHD_AcceptPolicyCallback apc, 1045 uint16_t port,
1033 void *apc_cls, 1046 MHD_AcceptPolicyCallback apc, void *apc_cls,
1034 MHD_AccessHandlerCallback dh, 1047 MHD_AccessHandlerCallback dh, void *dh_cls,
1035 void *dh_cls, ...); 1048 ...);
1049
1036 1050
1037/** 1051/**
1038 * Shutdown an http daemon. 1052 * Shutdown an http daemon.
1039 * 1053 *
1040 * @param daemon daemon to stop 1054 * @param daemon daemon to stop
1041 */ 1055 */
1042void MHD_stop_daemon (struct MHD_Daemon *daemon); 1056void
1057MHD_stop_daemon (struct MHD_Daemon *daemon);
1043 1058
1044 1059
1045/** 1060/**
@@ -1063,10 +1078,11 @@ void MHD_stop_daemon (struct MHD_Daemon *daemon);
1063 * not handle the connection (i.e. malloc failed, etc). 1078 * not handle the connection (i.e. malloc failed, etc).
1064 * The socket will be closed in any case. 1079 * The socket will be closed in any case.
1065 */ 1080 */
1066int MHD_add_connection (struct MHD_Daemon *daemon, 1081int
1067 int client_socket, 1082MHD_add_connection (struct MHD_Daemon *daemon,
1068 const struct sockaddr *addr, 1083 int client_socket,
1069 socklen_t addrlen); 1084 const struct sockaddr *addr,
1085 socklen_t addrlen);
1070 1086
1071 1087
1072/** 1088/**
@@ -1084,8 +1100,11 @@ int MHD_add_connection (struct MHD_Daemon *daemon,
1084 */ 1100 */
1085int 1101int
1086MHD_get_fdset (struct MHD_Daemon *daemon, 1102MHD_get_fdset (struct MHD_Daemon *daemon,
1087 fd_set * read_fd_set, 1103 fd_set *read_fd_set,
1088 fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd); 1104 fd_set *write_fd_set,
1105 fd_set *except_fd_set,
1106 int *max_fd);
1107
1089 1108
1090/** 1109/**
1091 * Obtain timeout value for select for this daemon (only needed if 1110 * Obtain timeout value for select for this daemon (only needed if
@@ -1115,7 +1134,8 @@ int MHD_get_timeout (struct MHD_Daemon *daemon,
1115 * daemon was not started with the right 1134 * daemon was not started with the right
1116 * options for this call. 1135 * options for this call.
1117 */ 1136 */
1118int MHD_run (struct MHD_Daemon *daemon); 1137int
1138MHD_run (struct MHD_Daemon *daemon);
1119 1139
1120 1140
1121/* **************** Connection handling functions ***************** */ 1141/* **************** Connection handling functions ***************** */
@@ -1135,6 +1155,7 @@ MHD_get_connection_values (struct MHD_Connection *connection,
1135 enum MHD_ValueKind kind, 1155 enum MHD_ValueKind kind,
1136 MHD_KeyValueIterator iterator, void *iterator_cls); 1156 MHD_KeyValueIterator iterator, void *iterator_cls);
1137 1157
1158
1138/** 1159/**
1139 * This function can be used to add an entry to 1160 * This function can be used to add an entry to
1140 * the HTTP headers of a connection (so that the 1161 * the HTTP headers of a connection (so that the
@@ -1167,7 +1188,9 @@ MHD_get_connection_values (struct MHD_Connection *connection,
1167int 1188int
1168MHD_set_connection_value (struct MHD_Connection *connection, 1189MHD_set_connection_value (struct MHD_Connection *connection,
1169 enum MHD_ValueKind kind, 1190 enum MHD_ValueKind kind,
1170 const char *key, const char *value); 1191 const char *key,
1192 const char *value);
1193
1171 1194
1172/** 1195/**
1173 * Sets the global error handler to a different implementation. "cb" 1196 * Sets the global error handler to a different implementation. "cb"
@@ -1184,7 +1207,9 @@ MHD_set_connection_value (struct MHD_Connection *connection,
1184 * @param cb new error handler 1207 * @param cb new error handler
1185 * @param cls passed to error handler 1208 * @param cls passed to error handler
1186 */ 1209 */
1187void MHD_set_panic_func (MHD_PanicCallback cb, void *cls); 1210void
1211MHD_set_panic_func (MHD_PanicCallback cb, void *cls);
1212
1188 1213
1189/** 1214/**
1190 * Get a particular header value. If multiple 1215 * Get a particular header value. If multiple
@@ -1195,9 +1220,11 @@ void MHD_set_panic_func (MHD_PanicCallback cb, void *cls);
1195 * @param key the header to look for 1220 * @param key the header to look for
1196 * @return NULL if no such item was found 1221 * @return NULL if no such item was found
1197 */ 1222 */
1198const char *MHD_lookup_connection_value (struct MHD_Connection *connection, 1223const char *
1199 enum MHD_ValueKind kind, 1224MHD_lookup_connection_value (struct MHD_Connection *connection,
1200 const char *key); 1225 enum MHD_ValueKind kind,
1226 const char *key);
1227
1201 1228
1202/** 1229/**
1203 * Queue a response to be transmitted to the client (as soon as 1230 * Queue a response to be transmitted to the client (as soon as
@@ -1211,7 +1238,8 @@ const char *MHD_lookup_connection_value (struct MHD_Connection *connection,
1211 */ 1238 */
1212int 1239int
1213MHD_queue_response (struct MHD_Connection *connection, 1240MHD_queue_response (struct MHD_Connection *connection,
1214 unsigned int status_code, struct MHD_Response *response); 1241 unsigned int status_code,
1242 struct MHD_Response *response);
1215 1243
1216 1244
1217/* **************** Response manipulation functions ***************** */ 1245/* **************** Response manipulation functions ***************** */
@@ -1231,12 +1259,11 @@ MHD_queue_response (struct MHD_Connection *connection,
1231 * @param crfc callback to call to free crc_cls resources 1259 * @param crfc callback to call to free crc_cls resources
1232 * @return NULL on error (i.e. invalid arguments, out of memory) 1260 * @return NULL on error (i.e. invalid arguments, out of memory)
1233 */ 1261 */
1234struct MHD_Response *MHD_create_response_from_callback (uint64_t size, 1262struct MHD_Response *
1235 size_t block_size, 1263MHD_create_response_from_callback (uint64_t size,
1236 MHD_ContentReaderCallback 1264 size_t block_size,
1237 crc, void *crc_cls, 1265 MHD_ContentReaderCallback crc, void *crc_cls,
1238 MHD_ContentReaderFreeCallback 1266 MHD_ContentReaderFreeCallback crfc);
1239 crfc);
1240 1267
1241 1268
1242/** 1269/**
@@ -1252,10 +1279,11 @@ struct MHD_Response *MHD_create_response_from_callback (uint64_t size,
1252 * @return NULL on error (i.e. invalid arguments, out of memory) 1279 * @return NULL on error (i.e. invalid arguments, out of memory)
1253 * @deprecated use MHD_create_response_from_buffer instead 1280 * @deprecated use MHD_create_response_from_buffer instead
1254 */ 1281 */
1255struct MHD_Response *MHD_create_response_from_data (size_t size, 1282struct MHD_Response *
1256 void *data, 1283MHD_create_response_from_data (size_t size,
1257 int must_free, 1284 void *data,
1258 int must_copy); 1285 int must_free,
1286 int must_copy);
1259 1287
1260 1288
1261/** 1289/**
@@ -1313,10 +1341,10 @@ MHD_create_response_from_buffer (size_t size,
1313 * data; will be closed when response is destroyed; 1341 * data; will be closed when response is destroyed;
1314 * fd should be in 'blocking' mode 1342 * fd should be in 'blocking' mode
1315 * @return NULL on error (i.e. invalid arguments, out of memory) 1343 * @return NULL on error (i.e. invalid arguments, out of memory)
1316 * @deprecated use MHD_create_response_from_fd_at_offset instead
1317 */ 1344 */
1318struct MHD_Response *MHD_create_response_from_fd (size_t size, 1345struct MHD_Response *
1319 int fd); 1346MHD_create_response_from_fd (size_t size,
1347 int fd);
1320 1348
1321 1349
1322/** 1350/**
@@ -1327,12 +1355,17 @@ struct MHD_Response *MHD_create_response_from_fd (size_t size,
1327 * @param fd file descriptor referring to a file on disk with the 1355 * @param fd file descriptor referring to a file on disk with the
1328 * data; will be closed when response is destroyed; 1356 * data; will be closed when response is destroyed;
1329 * fd should be in 'blocking' mode 1357 * fd should be in 'blocking' mode
1330 * @param off offset to start reading from in the file 1358 * @param off offset to start reading from in the file;
1359 * Be careful! 'off_t' may have been compiled to be a
1360 * 64-bit variable for MHD, in which case your application
1361 * also has to be compiled using the same options! Read
1362 * the MHD manual for more details.
1331 * @return NULL on error (i.e. invalid arguments, out of memory) 1363 * @return NULL on error (i.e. invalid arguments, out of memory)
1332 */ 1364 */
1333struct MHD_Response *MHD_create_response_from_fd_at_offset (size_t size, 1365struct MHD_Response *
1334 int fd, 1366MHD_create_response_from_fd_at_offset (size_t size,
1335 off_t offset); 1367 int fd,
1368 off_t offset);
1336 1369
1337 1370
1338/** 1371/**
@@ -1345,6 +1378,7 @@ struct MHD_Response *MHD_create_response_from_fd_at_offset (size_t size,
1345 */ 1378 */
1346void MHD_destroy_response (struct MHD_Response *response); 1379void MHD_destroy_response (struct MHD_Response *response);
1347 1380
1381
1348/** 1382/**
1349 * Add a header line to the response. 1383 * Add a header line to the response.
1350 * 1384 *
@@ -1432,13 +1466,12 @@ const char *MHD_get_response_header (struct MHD_Response *response,
1432 * Must NOT be NULL. 1466 * Must NOT be NULL.
1433 * @param cls first argument to ikvi 1467 * @param cls first argument to ikvi
1434 * @return NULL on error (out of memory, unsupported encoding), 1468 * @return NULL on error (out of memory, unsupported encoding),
1435 otherwise a PP handle 1469 * otherwise a PP handle
1436 */ 1470 */
1437struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection 1471struct MHD_PostProcessor *
1438 *connection, 1472MHD_create_post_processor (struct MHD_Connection *connection,
1439 size_t buffer_size, 1473 size_t buffer_size,
1440 MHD_PostDataIterator 1474 MHD_PostDataIterator iter, void *cls);
1441 iter, void *cls);
1442 1475
1443/** 1476/**
1444 * Parse and process POST data. 1477 * Parse and process POST data.
@@ -1467,7 +1500,8 @@ MHD_post_process (struct MHD_PostProcessor *pp,
1467 * problems; it is common to ignore the return 1500 * problems; it is common to ignore the return
1468 * value of this function 1501 * value of this function
1469 */ 1502 */
1470int MHD_destroy_post_processor (struct MHD_PostProcessor *pp); 1503int
1504MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
1471 1505
1472 1506
1473/* ********************* Digest Authentication functions *************** */ 1507/* ********************* Digest Authentication functions *************** */
@@ -1541,8 +1575,8 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection,
1541 * to the username if found 1575 * to the username if found
1542 */ 1576 */
1543char * 1577char *
1544MHD_basic_auth_get_username_password(struct MHD_Connection *connection, 1578MHD_basic_auth_get_username_password (struct MHD_Connection *connection,
1545 char** password); 1579 char** password);
1546 1580
1547/** 1581/**
1548 * Queues a response to request basic authentication from the client 1582 * Queues a response to request basic authentication from the client
@@ -1552,9 +1586,9 @@ MHD_basic_auth_get_username_password(struct MHD_Connection *connection,
1552 * @return MHD_YES on success, MHD_NO otherwise 1586 * @return MHD_YES on success, MHD_NO otherwise
1553 */ 1587 */
1554int 1588int
1555MHD_queue_basic_auth_fail_response(struct MHD_Connection *connection, 1589MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection,
1556 const char *realm, 1590 const char *realm,
1557 struct MHD_Response *response); 1591 struct MHD_Response *response);
1558 1592
1559/* ********************** generic query functions ********************** */ 1593/* ********************** generic query functions ********************** */
1560 1594
@@ -1605,14 +1639,44 @@ union MHD_ConnectionInfo
1605 * @return NULL if this information is not available 1639 * @return NULL if this information is not available
1606 * (or if the infoType is unknown) 1640 * (or if the infoType is unknown)
1607 */ 1641 */
1608const union MHD_ConnectionInfo *MHD_get_connection_info (struct MHD_Connection 1642const union MHD_ConnectionInfo *
1609 *connection, 1643MHD_get_connection_info (struct MHD_Connection *connection,
1610 enum 1644 enum MHD_ConnectionInfoType infoType,
1611 MHD_ConnectionInfoType 1645 ...);
1612 infoType, ...);
1613 1646
1614 1647
1615/** 1648/**
1649 * MHD connection options. Given to 'MHD_set_connection_option' to
1650 * set custom options for a particular connection.
1651 */
1652enum MHD_CONNECTION_OPTION
1653{
1654
1655 /**
1656 * Set a custom timeout for the given connection. Specified
1657 * as the number of seconds, given as an 'unsigned int'. Use
1658 * zero for no timeout.
1659 */
1660 MHD_CONNECTION_OPTION_TIMEOUT
1661
1662};
1663
1664
1665/**
1666 * Set a custom option for the given connection, overriding defaults.
1667 *
1668 * @param connection connection to modify
1669 * @param option option to set
1670 * @param ... arguments to the option, depending on the option type
1671 * @return MHD_YES on success, MHD_NO if setting the option failed
1672 */
1673int
1674MHD_set_connection_option (struct MHD_Connection *connection,
1675 enum MHD_CONNECTION_OPTION option,
1676 ...);
1677
1678
1679/**
1616 * Information about an MHD daemon. 1680 * Information about an MHD daemon.
1617 */ 1681 */
1618union MHD_DaemonInfo 1682union MHD_DaemonInfo
@@ -1643,16 +1707,19 @@ union MHD_DaemonInfo
1643 * @return NULL if this information is not available 1707 * @return NULL if this information is not available
1644 * (or if the infoType is unknown) 1708 * (or if the infoType is unknown)
1645 */ 1709 */
1646const union MHD_DaemonInfo *MHD_get_daemon_info (struct MHD_Daemon *daemon, 1710const union MHD_DaemonInfo *
1647 enum MHD_DaemonInfoType 1711MHD_get_daemon_info (struct MHD_Daemon *daemon,
1648 infoType, ...); 1712 enum MHD_DaemonInfoType infoType,
1713 ...);
1714
1649 1715
1650/** 1716/**
1651 * Obtain the version of this library 1717 * Obtain the version of this library
1652 * 1718 *
1653 * @return static version string, e.g. "0.9.9" 1719 * @return static version string, e.g. "0.9.9"
1654 */ 1720 */
1655const char* MHD_get_version(void); 1721const char*
1722MHD_get_version (void);
1656 1723
1657#if 0 /* keep Emacsens' auto-indent happy */ 1724#if 0 /* keep Emacsens' auto-indent happy */
1658{ 1725{