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.h81
1 files changed, 80 insertions, 1 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 3a46c085..c77ea6b9 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -84,7 +84,7 @@ extern "C"
84/** 84/**
85 * Current version of the library. 85 * Current version of the library.
86 */ 86 */
87#define MHD_VERSION 0x00000004 87#define MHD_VERSION 0x00000005
88 88
89/** 89/**
90 * MHD-internal return codes. 90 * MHD-internal return codes.
@@ -428,6 +428,11 @@ struct MHD_Connection;
428struct MHD_Response; 428struct MHD_Response;
429 429
430/** 430/**
431 * Handle for POST processing.
432 */
433struct MHD_PostProcessor;
434
435/**
431 * Allow or deny a client to connect. 436 * Allow or deny a client to connect.
432 * 437 *
433 * 438 *
@@ -555,6 +560,29 @@ typedef int
555typedef void (*MHD_ContentReaderFreeCallback) (void *cls); 560typedef void (*MHD_ContentReaderFreeCallback) (void *cls);
556 561
557/** 562/**
563 * Iterator over key-value pairs where the value
564 * maybe made available in increments and/or may
565 * not be zero-terminated.
566 *
567 * @param cls user-specified closure
568 * @param kind type of the value
569 * @param 0-terminated key for the value
570 * @param value pointer to size bytes of data at the
571 * specified offset
572 * @param off offset of value in the overall data
573 * @param size number of bytes in value available
574 * @return MHD_YES to continue iterating,
575 * MHD_NO to abort the iteration
576 */
577typedef int
578 (*MHD_IncrementalKeyValueIterator) (void *cls,
579 enum MHD_ValueKind kind,
580 const char *key,
581 const char *value,
582 size_t off,
583 size_t size);
584
585/**
558 * Start a webserver on the given port. 586 * Start a webserver on the given port.
559 * @param flags combination of MHD_FLAG values 587 * @param flags combination of MHD_FLAG values
560 * @param port port to bind to 588 * @param port port to bind to
@@ -776,6 +804,57 @@ const char *MHD_get_response_header (struct MHD_Response *response,
776 const char *key); 804 const char *key);
777 805
778 806
807/**
808 * Create a PostProcessor.
809 *
810 * A PostProcessor can be used to (incrementally)
811 * parse the data portion of a POST request.
812 *
813 * @param connection the connection on which the POST is
814 * happening (used to determine the POST format)
815 * @param buffer_size maximum number of bytes to use for
816 * internal buffering (used only for the parsing,
817 * specifically the parsing of the keys). A
818 * tiny value (256-1024) should be sufficient.
819 * Do NOT use 0.
820 * @param ikvi iterator to be called with the parsed data,
821 * Must NOT be NULL.
822 * @param cls first argument to ikvi
823 * @return NULL on error (out of memory, unsupported encoding),
824 otherwise a PP handle
825 */
826struct MHD_PostProcessor *
827MHD_create_post_processor(struct MHD_Connection * connection,
828 unsigned int buffer_size,
829 MHD_IncrementalKeyValueIterator ikvi,
830 void * cls);
831
832/**
833 * Parse and process POST data.
834 * Call this function when POST data is available
835 * (usually during an MHD_AccessHandlerCallback)
836 * with the upload_data and upload_data_size.
837 * Whenever possible, this will then cause calls
838 * to the MHD_IncrementalKeyValueIterator.
839 *
840 * @param pp the post processor
841 * @param post_data post_data_len bytes of POST data
842 * @param post_data_len length of post_data
843 * @return MHD_YES on success, MHD_NO on error
844 * (out-of-memory, iterator aborted, parse error)
845 */
846int
847MHD_post_process(struct MHD_PostProcessor * pp,
848 const char * post_data,
849 unsigned int post_data_len);
850
851/**
852 * Release PostProcessor resources.
853 */
854void
855MHD_destroy_post_processor(struct MHD_PostProcessor * pp);
856
857
779#if 0 /* keep Emacsens' auto-indent happy */ 858#if 0 /* keep Emacsens' auto-indent happy */
780{ 859{
781#endif 860#endif