Up: microhttpd-post   [Contents][Index]


11.1 Programming interface for the POST processor

Function: struct MHD_PostProcessor * MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iterator, void *iterator_cls)

Create a PostProcessor. A PostProcessor can be used to (incrementally) parse the data portion of a POST request.

connection

the connection on which the POST is happening (used to determine the POST format);

buffer_size

maximum number of bytes to use for internal buffering (used only for the parsing, specifically the parsing of the keys). A tiny value (256-1024) should be sufficient; do NOT use a value smaller than 256; for good performance, use 32k or 64k (i.e. 65536).

iterator

iterator to be called with the parsed data; must NOT be NULL;

iterator_cls

custom value to be used as first argument to iterator.

Return NULL on error (out of memory, unsupported encoding), otherwise a PP handle.

Function: enum MHD_Result MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)

Parse and process POST data. Call this function when POST data is available (usually during an MHD_AccessHandlerCallback) with the upload_data and upload_data_size. Whenever possible, this will then cause calls to the MHD_IncrementalKeyValueIterator.

pp

the post processor;

post_data

post_data_len bytes of POST data;

post_data_len

length of post_data.

Return MHD_YES on success, MHD_NO on error (out-of-memory, iterator aborted, parse error).

Function: enum MHD_Result MHD_destroy_post_processor (struct MHD_PostProcessor *pp)

Release PostProcessor resources. After this function is being called, the PostProcessor is guaranteed to no longer call its iterator. There is no special call to the iterator to indicate the end of the post processing stream. After destroying the PostProcessor, the programmer should perform any necessary work to complete the processing of the iterator.

Return MHD_YES if processing completed nicely, MHD_NO if there were spurious characters or formatting problems with the post request. It is common to ignore the return value of this function.


Up: microhttpd-post   [Contents][Index]