Hello Austin,
As Christian explained, via "upload_data" you can receive any payload kind. I'm writting a library which maps MHD callbacks to "objects" and it needs to support the following features:
1. receive one or more files on demand (to receive large files about 5 GB+ without "frying" CPU/RAM) in same request (files via form-data);
2. receive form fields (HTML-form fields via x-www-form-urlencoded);
3. 1 and 2 (both files and fields via form-data);
4. payload contents (raw-data, json/xml and so on via application/<type>);
5. handlers to create customized 'body-parser' if none of the above options fits.
it seems the option 4 above is the one you are looking for. For example, supposing you need to send a JSON "{"foo":"bar"}" to the server, in the client:
and in a minimal snipped server example, you can receive it as:
...
static void req_cb(void *cls, struct bk_httpreq *req, struct bk_httpres *res) {
struct bk_str *payload = bk_httpreq_payload(req);
printf("Payload string: %s; Size: %zd", bk_str_content(payload), bk_str_length(payload));
...
}
int main(void) {
struct bk_httpsrv *srv = bk_httpsrv_new(req_cb, NULL);
bk_httpsrv_listen(srv, 8080, false);
...
}
...
then it prints "Payload string: {"foo":"bar"}; Size: 13" in the terminal. The "payload" variable above is an instance of the object "bk_str" which contains useful "methods" for string handling like "content", "length", "clear", "printf" and more.
If you want to take a look how it was implemented, please use the branch "new_api" and specifically the line 78 from bk_httpuplds.c file:
hope this help you.
(the library is under development, so there is parts undocumented yet but feel free to send any questions via Github issues)