|
From: | Kenneth Mastro |
Subject: | Re: [libmicrohttpd] issue in storing incrementally received data chunks from upload_data |
Date: | Tue, 24 Feb 2015 08:46:59 -0500 |
Hello all,I am using MHD daemon server in order to send incrementally large strings containing xml data.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).The problem is that the string in which i append incrementally the data chunks as they arrive is always bigger than the data it has been sent/received.I do not understand where from comes this additional data and why my postXMLData variable gets always larger.My code looks like this:static postXMLData = "";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 structuresif (*con_cls == NULL){*con_cls = &i;return MHD_YES;}// next calls - receive data incrementallyif (*upload_data_size != 0){xmlDataString.append(upload_data);(*upload_data_size) = 0;return MHD_YES;}// last call - upload_data_size = 0 - processed received dataif (*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;}
[Prev in Thread] | Current Thread | [Next in Thread] |