aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-01-10 01:02:58 +0000
committerChristian Grothoff <christian@grothoff.org>2007-01-10 01:02:58 +0000
commitefc8c3cc538f6172246e89998ac22a1e655f7df1 (patch)
tree06e07a64bb5ab00696ae794b90121dbd241f5c3c
parent87903ed8f3bdcc8b26aa01e322548aba320132d0 (diff)
downloadlibmicrohttpd-efc8c3cc538f6172246e89998ac22a1e655f7df1.tar.gz
libmicrohttpd-efc8c3cc538f6172246e89998ac22a1e655f7df1.zip
syn
-rw-r--r--src/include/microhttpd.h98
1 files changed, 65 insertions, 33 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 52070284..58e3d1ab 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -57,6 +57,11 @@ extern "C" {
57 57
58#define MHD_NO 0 58#define MHD_NO 0
59 59
60#define MHD_HTTP_OK 200
61
62#define MHD_HTTP_NOT_FOUND 404
63
64
60/** 65/**
61 * Options for the MHD daemon. Note that if neither 66 * Options for the MHD daemon. Note that if neither
62 * MHD_USER_THREAD_PER_CONNECTION nor MHD_USE_SELECT_INTERNALLY are 67 * MHD_USER_THREAD_PER_CONNECTION nor MHD_USE_SELECT_INTERNALLY are
@@ -110,6 +115,39 @@ enum MHD_OPTION {
110 MHD_USE_IPv6 = 32, 115 MHD_USE_IPv6 = 32,
111}; 116};
112 117
118/**
119 * The MHD_ValueKind specifies the source of
120 * the key-value pairs in the HTTP protocol.
121 */
122enum MHD_ValueKind {
123
124 /**
125 * Response header
126 */
127 MHD_RESPONSE_HEADER_KIND = 0;
128
129 /**
130 * HTTP header
131 */
132 MHD_HEADER_KIND = 1;
133
134 /**
135 * Cookies
136 */
137 MHD_COOKIE_KIND = 2;
138
139 /**
140 * POST data
141 */
142 MHD_POSTDATA_KIND = 4;
143
144 /**
145 * GET (URI) arguments
146 */
147 MHD_GET_ARGUMENT_KIND = 8;
148
149};
150
113struct MHD_Daemon; 151struct MHD_Daemon;
114 152
115struct MHD_Session; 153struct MHD_Session;
@@ -131,9 +169,9 @@ typedef int
131 169
132/** 170/**
133 * A client has requested the given url using the given method ("GET", 171 * A client has requested the given url using the given method ("GET",
134 * "PUT" or "POST"). The callback must call MHS callbacks to provide 172 * "PUT", "DELETE", "POST", etc). The callback must call MHS
135 * content to give back to the client and return an HTTP status code 173 * callbacks to provide content to give back to the client and return
136 * (i.e. 200 for OK, 404, etc.). 174 * an HTTP status code (i.e. 200 for OK, 404, etc.).
137 * 175 *
138 * @return MHS_YES if the connection was handled successfully, 176 * @return MHS_YES if the connection was handled successfully,
139 * MHS_NO if the socket must be closed due to a serios 177 * MHS_NO if the socket must be closed due to a serios
@@ -157,6 +195,7 @@ typedef int
157 */ 195 */
158typedef int 196typedef int
159(*MHD_KeyValueIterator)(void * cls, 197(*MHD_KeyValueIterator)(void * cls,
198 enum MHD_ValueKind kind,
160 const char * key, 199 const char * key,
161 const char * value); 200 const char * value);
162 201
@@ -239,7 +278,7 @@ int
239MHD_get_fdset(struct MHD_Daemon * daemon, 278MHD_get_fdset(struct MHD_Daemon * daemon,
240 fd_set * read_fd_set, 279 fd_set * read_fd_set,
241 fd_set * write_fd_set, 280 fd_set * write_fd_set,
242 fd_set * exc_fd_set, 281 fd_set * except_fd_set,
243 int * max_fd); 282 int * max_fd);
244 283
245/** 284/**
@@ -292,42 +331,22 @@ MHD_unregister_handler(struct MHD_Daemon * daemon,
292 * @return number of entries iterated over 331 * @return number of entries iterated over
293 */ 332 */
294int 333int
295MHD_get_session_headers(struct MHD_Session * session, 334MHD_get_session_values(struct MHD_Session * session,
296 MHD_KeyValueIterator * iterator, 335 enum MHD_ValueKind kind,
297 void * iterator_cls); 336 MHD_KeyValueIterator * iterator,
337 void * iterator_cls);
298 338
299/** 339/**
300 * Get a particular header value. 340 * Get a particular header value. If multiple
341 * values match the kind, return any one of them.
301 * 342 *
302 * @param key the header to look for 343 * @param key the header to look for
303 * @return NULL if no such item was found 344 * @return NULL if no such item was found
304 */ 345 */
305const char * 346const char *
306MHD_lookup_session_header(struct MHD_Session * session, 347MHD_lookup_session_value(struct MHD_Session * session,
307 const char * key); 348 enum MHD_ValueKind kind,
308 349 const char * key);
309/**
310 * Get all of the form fields from POST.
311 *
312 * @param iterator callback to call on each header;
313 * maybe NULL (then just count headers)
314 * @param iterator_cls extra argument to iterator
315 * @return number of entries iterated over
316 */
317int
318MHD_get_post_items(struct MHD_Session * session,
319 MHD_KeyValueIterator * iterator,
320 void * iterator_cls);
321
322/**
323 * Get a particular form field from POST.
324 *
325 * @param key the field to look for
326 * @return NULL if no such item was found
327 */
328const char *
329MHD_lookup_post_item(struct MHD_Session * session,
330 const char * key);
331 350
332/** 351/**
333 * Queue a response to be transmitted to the client (as soon as 352 * Queue a response to be transmitted to the client (as soon as
@@ -343,6 +362,7 @@ int
343MHD_queue_response(struct MHD_Session * session, 362MHD_queue_response(struct MHD_Session * session,
344 unsigned int status_code, 363 unsigned int status_code,
345 struct MHD_Response * response); 364 struct MHD_Response * response);
365
346 366
347/** 367/**
348 * Create a response object. The response object can be extended with 368 * Create a response object. The response object can be extended with
@@ -420,6 +440,18 @@ MHD_get_response_headers(struct MHD_Response * response,
420 MHD_KeyValueIterator * iterator, 440 MHD_KeyValueIterator * iterator,
421 void * iterator_cls); 441 void * iterator_cls);
422 442
443/**
444 * FIXME-CHRIS
445 * @return -1 if no data uploaded; otherwise number of bytes
446 * read into buf; 0 for end of transmission
447 */
448int
449MHD_read_file_upload(struct MHD_Session * session,
450 void * buf,
451 size_t len);
452
453
454
423#if 0 /* keep Emacsens' auto-indent happy */ 455#if 0 /* keep Emacsens' auto-indent happy */
424{ 456{
425#endif 457#endif