[libmicrohttpd] MHD_create_response_from_callback() not called on POST

2016-09-27 Thread Leonard Bocock
Hi

Building a basic lightweight server that handles Server Side Events (using HTTP 
GET is working) and JSON request/response using POST’d data request and 
formatting a JSON response.  

Provided the following is used (unsure why), JSON data appears in the response 
callback function parameters, along with data length. The request is small in 
length.

MHD_create_response_from_callback()if (&aptr != *ptr) {
*ptr = &aptr;
return MHD_YES;
}

However, I want to bypass MHD_create_post_processor () and simply respond back 
to the client using MHD_create_response_from_callback(). Except the callback 
handler is never called. It’s the same approach I’m using for the SSE GET, and 
that works fine.

Is this by design I assume? Is there away, when handling a POST response, to 
invoke the response handler callback? Or  is the only answer to mock up my own 
MHD_create_post_processor construct to process JSON data?

Thanks, Leonard.


Re: [libmicrohttpd] MHD_create_response_from_callback() not called on POST

2016-09-27 Thread Christian Grothoff
Hi Leonard,

I suspect you're queuing the response at a time where MHD disallows it,
and then don't check the return value so you don't see the error message.

Anyway, if you want to study POST processing of JSON with MHD, we have a
big implementation doing just that in the Taler codebase at

https://www.git.taler.net/?p=exchange.git;a=tree;f=src/exchange;h=e59eb52b1b3e0c8b1a4394c0e372a1adb3d4aace;hb=HEAD

Happy hacking!

Christian

On 09/27/2016 11:44 AM, Leonard Bocock wrote:
> Hi
> 
> Building a basic lightweight server that handles Server Side Events (using 
> HTTP GET is working) and JSON request/response using POST’d data request and 
> formatting a JSON response.  
> 
> Provided the following is used (unsure why), JSON data appears in the 
> response callback function parameters, along with data length. The request is 
> small in length.
> 
> MHD_create_response_from_callback()if (&aptr != *ptr) {
> *ptr = &aptr;
> return MHD_YES;
> }
> 
> However, I want to bypass MHD_create_post_processor () and simply respond 
> back to the client using MHD_create_response_from_callback(). Except the 
> callback handler is never called. It’s the same approach I’m using for the 
> SSE GET, and that works fine.
> 
> Is this by design I assume? Is there away, when handling a POST response, to 
> invoke the response handler callback? Or  is the only answer to mock up my 
> own MHD_create_post_processor construct to process JSON data?
> 
> Thanks, Leonard.
> 


0xE29FC3CC.asc
Description: application/pgp-keys


signature.asc
Description: OpenPGP digital signature