The size of the sent data chuck(from curls) is equal with the sum of the received data chucks
(received data size in MHD daemon server == sum of all upload_data_size for a specific connection).
static int AnswerToConnection (void *cls, struct MHD_Connection *connection,
const char *url, const char *method, const char *version,
const char *upload_data, size_t *upload_data_size, void **con_cls)
{
static int i;
// the first call - initialize data structures
if (*con_cls == NULL)
{
*con_cls = &i;
return MHD_YES;
}
// next calls - receive data incrementally
if (*upload_data_size != 0)
{
xmlDataString.append(upload_data);
(*upload_data_size) = 0;
return MHD_YES;
}
// last call - upload_data_size = 0 - processed received data
if (*upload_data_size == 0)
{
FILE *f;
f=fopen("test_data_output_2.txt", "w");
fprintf(f, "%s", postXMLData .c_str());
fclose(f);
}
int ret = pProcessRequest->SendPage(connection, ANSWER_PAGE);
return ret;
}