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.h65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index b8209862..ae918b4a 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -133,19 +133,15 @@ extern "C" {
133 * used, the client wants control over the process and will call the 133 * used, the client wants control over the process and will call the
134 * appropriate microhttpd callbacks.<p> 134 * appropriate microhttpd callbacks.<p>
135 * 135 *
136 * Note that it is legal to specify that both IPv4 and IPv6
137 * should be used. However, if neither IPv4 nor IPv6 is
138 * specified, starting the daemon will fail.<p>
139 *
140 * Starting the daemon may also fail if a particular option is not 136 * Starting the daemon may also fail if a particular option is not
141 * implemented or not supported on the target platform (i.e. no 137 * implemented or not supported on the target platform (i.e. no
142 * support for SSL, threads or IPv6). 138 * support for SSL, threads or IPv6).
143 */ 139 */
144enum MHD_OPTION { 140enum MHD_FLAG {
145 /** 141 /**
146 * No options selected. 142 * No options selected.
147 */ 143 */
148 MHD_NO_OPTION = 0, 144 MHD_NO_FLAG = 0,
149 145
150 /** 146 /**
151 * Run in debug mode. If this flag is used, the 147 * Run in debug mode. If this flag is used, the
@@ -170,14 +166,29 @@ enum MHD_OPTION {
170 MHD_USE_SELECT_INTERNALLY = 8, 166 MHD_USE_SELECT_INTERNALLY = 8,
171 167
172 /** 168 /**
173 * Run using the IPv4 protocol 169 * Run using the IPv6 protocol (otherwise, MHD will
170 * just support IPv4).
171 */
172 MHD_USE_IPv6 = 16,
173
174};
175
176/**
177 * MHD options. Passed in the varargs portion
178 * of MHD_start_daemon.
179 */
180enum MHD_OPTION {
181
182 /**
183 * No more options / last option. This is used
184 * to terminate the VARARGs list.
174 */ 185 */
175 MHD_USE_IPv4 = 16, 186 MHD_OPTION_END = 0,
176 187
177 /** 188 /**
178 * Run using the IPv6 protocol 189 * FIXME: add options for buffer sizes here...
179 */ 190 */
180 MHD_USE_IPv6 = 32, 191
181}; 192};
182 193
183/** 194/**
@@ -215,7 +226,7 @@ enum MHD_ValueKind {
215 226
216struct MHD_Daemon; 227struct MHD_Daemon;
217 228
218struct MHD_Session; 229struct MHD_Connection;
219 230
220struct MHD_Response; 231struct MHD_Response;
221 232
@@ -238,6 +249,9 @@ typedef int
238 * callbacks to provide content to give back to the client and return 249 * callbacks to provide content to give back to the client and return
239 * an HTTP status code (i.e. 200 for OK, 404, etc.). 250 * an HTTP status code (i.e. 200 for OK, 404, etc.).
240 * 251 *
252 * @param url the requested url
253 * @param method the HTTP method used ("GET", "PUT", etc.)
254 * @param version the HTTP version string (i.e. "HTTP/1.1")
241 * @param upload_data_size set initially to the size of the 255 * @param upload_data_size set initially to the size of the
242 * upload_data provided; the method must update this 256 * upload_data provided; the method must update this
243 * value to the number of bytes NOT processed 257 * value to the number of bytes NOT processed
@@ -247,9 +261,10 @@ typedef int
247 */ 261 */
248typedef int 262typedef int
249(*MHD_AccessHandlerCallback)(void * cls, 263(*MHD_AccessHandlerCallback)(void * cls,
250 struct MHD_Session * session, 264 struct MHD_Connection * connection,
251 const char * url, 265 const char * url,
252 const char * method, 266 const char * method,
267 const char * version,
253 const char * upload_data, 268 const char * upload_data,
254 unsigned int * upload_data_size); 269 unsigned int * upload_data_size);
255 270
@@ -312,21 +327,25 @@ typedef void
312 327
313/** 328/**
314 * Start a webserver on the given port. 329 * Start a webserver on the given port.
330 * @param flags combination of MHD_FLAG values
315 * @param port port to bind to 331 * @param port port to bind to
316 * @param apc callback to call to check which clients 332 * @param apc callback to call to check which clients
317 * will be allowed to connect 333 * will be allowed to connect
318 * @param apc_cls extra argument to apc 334 * @param apc_cls extra argument to apc
319 * @param dh default handler for all URIs 335 * @param dh default handler for all URIs
320 * @param dh_cls extra argument to dh 336 * @param dh_cls extra argument to dh
337 * @param ... list of options (type-value pairs,
338 * terminated with MHD_OPTION_END).
321 * @return NULL on error, handle to daemon on success 339 * @return NULL on error, handle to daemon on success
322 */ 340 */
323struct MHD_Daemon * 341struct MHD_Daemon *
324MHD_start_daemon(unsigned int options, 342MHD_start_daemon(unsigned int flags,
325 unsigned short port, 343 unsigned short port,
326 MHD_AcceptPolicyCallback apc, 344 MHD_AcceptPolicyCallback apc,
327 void * apc_cls, 345 void * apc_cls,
328 MHD_AccessHandlerCallback dh, 346 MHD_AccessHandlerCallback dh,
329 void * dh_cls); 347 void * dh_cls,
348 ...);
330 349
331 350
332 351
@@ -401,10 +420,10 @@ MHD_unregister_handler(struct MHD_Daemon * daemon,
401 * @return number of entries iterated over 420 * @return number of entries iterated over
402 */ 421 */
403int 422int
404MHD_get_session_values(struct MHD_Session * session, 423MHD_get_connection_values(struct MHD_Connection * connection,
405 enum MHD_ValueKind kind, 424 enum MHD_ValueKind kind,
406 MHD_KeyValueIterator iterator, 425 MHD_KeyValueIterator iterator,
407 void * iterator_cls); 426 void * iterator_cls);
408 427
409/** 428/**
410 * Get a particular header value. If multiple 429 * Get a particular header value. If multiple
@@ -414,22 +433,22 @@ MHD_get_session_values(struct MHD_Session * session,
414 * @return NULL if no such item was found 433 * @return NULL if no such item was found
415 */ 434 */
416const char * 435const char *
417MHD_lookup_session_value(struct MHD_Session * session, 436MHD_lookup_connection_value(struct MHD_Connection * connection,
418 enum MHD_ValueKind kind, 437 enum MHD_ValueKind kind,
419 const char * key); 438 const char * key);
420 439
421/** 440/**
422 * Queue a response to be transmitted to the client (as soon as 441 * Queue a response to be transmitted to the client (as soon as
423 * possible). 442 * possible).
424 * 443 *
425 * @param session the session identifying the client 444 * @param connection the connection identifying the client
426 * @param status_code HTTP status code (i.e. 200 for OK) 445 * @param status_code HTTP status code (i.e. 200 for OK)
427 * @param response response to transmit 446 * @param response response to transmit
428 * @return MHD_NO on error (i.e. reply already sent), 447 * @return MHD_NO on error (i.e. reply already sent),
429 * MHD_YES on success or if message has been queued 448 * MHD_YES on success or if message has been queued
430 */ 449 */
431int 450int
432MHD_queue_response(struct MHD_Session * session, 451MHD_queue_response(struct MHD_Connection * connection,
433 unsigned int status_code, 452 unsigned int status_code,
434 struct MHD_Response * response); 453 struct MHD_Response * response);
435 454