Re: apreq_parse_generic example
Joseph Schaefer <[email protected]> Sat, 9 Nov 2013 15:04:21 -0500
| Newsgroups | gmane.comp.apache.apreq |
|---|---|
| Message-ID | <[email protected]> |
No that=92s fine if you don=92t mind enabling your the parser for ALL json stuff. It=92d probably have been saner for us to have the dummy param appear in the body table, but what you=92re doing will work reliably and isn=92t too much more conceptually difficult. On Nov 9, 2013, at 3:00 PM, Brian J. France <[email protected]> = wrote: > Finally got some working code. Registered the parser for the content = type: >=20 > apreq_register_parser("application/json", apreq_parse_generic); >=20 > in a pre_init hook, then normal apreq_handle_apache2 and apreq_body = calls, then a apreq_parser_get call to get the parser and: >=20 > dummy =3D *(apreq_param_t **)parser->ctx; > apr_brigade_pflatten(dummy->upload, &val, &vlen, r->pool); >=20 > to get the string of the body in val/vlen. Is there a better way? >=20 > Thanks, >=20 > Brian >=20 > On Nov 9, 2013, at 9:32 AM, Joseph Schaefer <[email protected]> = wrote: >=20 >> The generic parser stores the POST data in the upload >> brigade of a param named =93_dummy_=94 but it=92s not in >> the output table, its in the parser=92s ctx pointer. >> The struct is declared in parser.c so it=92s technically >> private but the param is in the first slot and that=92s >> meant to be public. >>=20 >> On Nov 8, 2013, at 1:02 PM, Joseph Schaefer <[email protected]> = wrote: >>=20 >>> Been a while since I thought about this, but >>> apreq is really only suited for table-based >>> data structures. JSON is a little too generic >>> for that unless you know the data is restricted >>> to only key-value pairs. >>>=20 >>> On Nov 8, 2013, at 12:45 PM, Brian J. France <[email protected]> = wrote: >>>=20 >>>> Does anybody have example code of how to use apreq_parse_generic in = an httpd module hook (non-handler)? >>>>=20 >>>> Need to use apreq2 and mod_apreq2 to read json data and not having = any luck. >>>>=20 >>>> Thanks, >>>>=20 >>>> Brian >>>>=20 >>>> - Please keep me looped into any reply, not subscribed. >>>=20 >>=20 >>=20 >=20