static void req_cb(__SG_UNUSED void *cls, __SG_UNUSED struct sg_httpreq *req, __SG_UNUSED struct sg_httpres *res) {
struct sg_str *payload = sg_httpreq_payload(req);
sg_httpres_send(res, sg_str_content(payload), "text/plain", 200);
}
and this in the client side (exemplifying in cURL):
curl --header "Content-Type: application/json" --request POST --data '{"abc":123}' -w "\n" http://localhost:<PORT>
static void process_uploads(struct sg_httpreq *req, struct sg_httpres *res) {
struct sg_httpupld *upld;
...
upld = sg_httpreq_uploads(req); // first uploaded file
while (upld) {
name = sg_httpupld_name(upld);
if ((errnum = sg_httpupld_save(upld, true)) == 0) // save the file
sg_str_printf(body, "<li><a href="">\"?file=%s\">%s</a></li>", name, name);
else {
sg_strerror(errnum, errmsg, sizeof(errmsg));
sg_str_printf(body, "<li><font color='red'>%s - failed - %s</font></li>", name, errmsg); // handle saving errors
}
sg_httpuplds_next(&upld); // next uploaded file
}
...
Maybe it can be used as a starting point for you to check how to handle the MHD's ... const char *upld_data, size_t *upld_data_size ... AHC parameters. The related lines I've used, are:
Hope this helps you. ☺