[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apreq-dev
Subject:    Re: apreq_parse_generic example
From:       Joseph Schaefer <joe_schaefer () yahoo ! com>
Date:       2013-11-09 20:04:21
Message-ID: 05A4A891-F69D-43DE-937D-CF7D25139D45 () yahoo ! com
[Download RAW message or body]

No that’s fine if you don’t mind enabling your the
parser for ALL json stuff.  It’d probably have been
saner for us to have the dummy param appear in the
body table, but what you’re doing will work reliably
and isn’t too much more conceptually difficult.


On Nov 9, 2013, at 3:00 PM, Brian J. France <brian@brianfrance.com> wrote:

> Finally got some working code. Registered the parser for the content type:
> 
> apreq_register_parser("application/json", apreq_parse_generic);
> 
> 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: 
> dummy = *(apreq_param_t **)parser->ctx;
> apr_brigade_pflatten(dummy->upload, &val, &vlen, r->pool);
> 
> to get the string of the body in val/vlen.  Is there a better way?
> 
> Thanks,
> 
> Brian
> 
> On Nov 9, 2013, at 9:32 AM, Joseph Schaefer <joe_schaefer@yahoo.com> wrote:
> 
> > The generic parser stores the POST data in the upload
> > brigade of a  param named “_dummy_” but it’s not in
> > the output table, its in the parser’s ctx pointer.
> > The struct is declared in parser.c so it’s technically
> > private but the param is in the first slot and that’s
> > meant to be public.
> > 
> > On Nov 8, 2013, at 1:02 PM, Joseph Schaefer <joe_schaefer@yahoo.com> wrote:
> > 
> > > 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.
> > > 
> > > On Nov 8, 2013, at 12:45 PM, Brian J. France <brian@brianfrance.com> wrote:
> > > 
> > > > Does anybody have example code of how to use apreq_parse_generic in an httpd \
> > > > module hook (non-handler)? 
> > > > Need to use apreq2 and mod_apreq2 to read json data and not having any luck.
> > > > 
> > > > Thanks,
> > > > 
> > > > Brian
> > > > 
> > > > - Please keep me looped into any reply, not subscribed.
> > > 
> > 
> > 
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic