libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] get all post data in a map


From: Kenneth Mastro
Subject: Re: [libmicrohttpd] get all post data in a map
Date: Mon, 25 Jan 2016 08:30:47 -0500

I'm not sure what the problem is, then.. I thought you said the request 'hangs on'?  So that's not the case..?  Your server IS responding to the request?

You don't need to 'terminate' the post-iterator callback function yourself from inside the callback.  It will stop being called when there is no more data to parse.

I do basically the same thing you're trying to do - put the post parameters into a map.  The callback doesn't get to decide when the post data has been completely processed - that's decided by your server (probably in your connection callback).  Maybe you're missing the step where you set the 'data size' pointer to 0 to tell MHD you've absorbed all the data from that chunk of the POST request?

The second-to-last parameter in the connection callback is a size_t* that represents the 'upload data size'.  You need to set the value to 0 if you absorbed all the data - very probably after you call 'MHD_post_process'.  Something like this:

if(*uploadDataSize != 0) {
    // process the post data using MHD's default post-processor - this will call your post-processor-callback function
    result = MHD_post_process(pointerToYourPostProcessorForThisConnection, uploadData, *uploadDataSize);
    // tell MHD you're done with all that data
    *uploadDataSize = 0;
}

POST data comes in chunks to MHD - so your 'connection callback' will be called repeatedly until the data is complete (or probably if you return MHD_NO, but I'm not sure).  So - If you put something like the above snippet in your connection callback, will ultimately be called repeatedly until MHD tells you that 'uploadDataSize' is 0 - that there is no more data to process.

After that point, MHD will stop sending you the POST data and your server can do whatever it wants with all the data you've collected.

In the snippet you sent, I don't see anything in there that actually CALLS the post processor (I see the create, but not the call to process the data).  I'm guessing that's what you're missing.

As a side note: MHD is really really great, but using it to process POST data is not trivial.  It took me a while to get right.  You should at least start with the example in the tutorial and go from there.

Hope that helps.


Ken











On Mon, Jan 25, 2016 at 8:06 AM, rahul bhola <address@hidden> wrote:
yes every response is just the url. I am still not doing anything with the post data. Just trying to store it in a map. Let me attach gist files for the same

here is the code snippets for the same


reply via email to

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