libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] issue in storing incrementally received data chunks from


From: dumitrița munteanu
Subject: [libmicrohttpd] issue in storing incrementally received data chunks from upload_data
Date: Tue, 24 Feb 2015 15:23:16 +0200


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 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;
}   

reply via email to

[Prev in Thread] Current Thread [Next in Thread]