libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] POST data processing


From: Christian Grothoff
Subject: Re: [libmicrohttpd] POST data processing
Date: Thu, 17 May 2018 13:05:02 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 05/17/2018 06:52 AM, Austin Einter wrote:
> Hello
> I am using libmicrohttpd and facing issue with POST processing.
> 
> The POST message received contains xml or json data. libmicrohttpd does
> not support xml / json. So I can not use post process or iterate
> callbacks for body data processing. In fact I tried and it does not work
> (iterate callbacks not called even when I call post process).
> 
> So I am left with two options.
> 
> 1) Either write body parser, where I need to take care of content-length
> case, chunked data case etc. 

Nope, that is _always_ take care of by MHD. You just need to feed the
"upload_data" you get in your MHD_AccessHandlerCallback as you receive
it to your XML or JSON parser, either incrementally or as a whole.

> Is there anyway in libmicrohttpd, I can collect the entire POST message
> as it comes / received at socket level?

Sure.  You should look at GNU Taler (https://git.taler.net/), the
exchange and the merchant-backend both use MHD to receive JSON-formatted
uploads.  The core logic for this is actually from/in GNUnet
(https://gnunet.org/git/, gnunet.git, src/json/json_mhd.c).  So if you
are happy with libjansson, you can link against libgnunetjson (like
Taler does) and use that code to parse JSON.

XML usage would be analogous (and this is ~200 LOC only).

Happy hacking!

Christian

Attachment: 0xE29FC3CC.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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