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: rahul bhola
Subject: Re: [libmicrohttpd] get all post data in a map
Date: Mon, 25 Jan 2016 16:17:00 +0000

Hi,
I followed what you told me in last mail and the browser started to get response even to post messages but i am still on able to access the map data. It shows me seg fault. Most of the codes are almost similar to what i found in example for the site. Can you please look over them once and guide me in the right direction.
Here is the link to the same
https://gist.github.com/georoot/aff2825e0177cb3cc1ae

thanks for helping me out.

On Mon, Jan 25, 2016 at 1:30 PM Kenneth Mastro <address@hidden> wrote:
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]