httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pranil dasika <pranil.das...@gmail.com>
Subject Re: Reading post parameters from apache request
Date Tue, 01 Dec 2009 11:43:34 GMT
On Mon, Nov 30, 2009 at 8:49 AM, Yoichi Kawasaki <yokawasa@gmail.com> wrote:

> 2009/11/21 Sorin Manolache <sorinm@gmail.com>:
> > On Fri, Nov 20, 2009 at 22:01, pranil dasika <pranil.dasika@gmail.com>
> wrote:
> >> Hi,
> >>
> >> I am trying to write a custom module where I need to read post
> parameters
> >> from the request. I guess apreq library is relevant to this but could
> not
> >> find any substantial examples or documents.
> >> Is there any other way to read the params other than apreq. Any
> pseudocode/
> >> examples will be appreciated.
> >>
> >> Thanks,
> >> Pranil
> >>
> >
> > Here you have an example. It is not optimal, you could, for example,
> > take the brigade creation out of the loop and clean the brigade at the
> > end of each iteration, after you extracted the data.
> >
> > apr_bucket_brigade *bb;
> > do {
> >   bb = apr_brigade_create(req->pool, req->connection->bucket_alloc);
> >   if (0 == bb)
> >        // error
> >   if (APR_SUCCESS != ap_get_brigade(req->input_filters, bb,
> > AP_MODE_READBYTES, APR_BLOCK_READ, 9216))
> >        // error
> >   extract data from bb;
> > } while (EOS not yet encountered in bb);
> >
> >
> > S
> >
>
>
> Hi
>
> I  have an another example. I read post parameters in the source code
> below:
>
> http://github.com/yokawasa/mod_akismet/blob/master/mod_akismet.c#L647
> line: 647 - 705
>
> hope this helps you.
>
> Yoichi
>
> --
> Yoichi Kawasaki <yokawasa@gmail.com>
>



Sorin, Yoichi,

Thanks for your responses. The below code worked for me using apreq.

const apr_table_t* args;
apreq_handle_t* h = apreq_handle_apache2(r);
apreq_body(h, &args);
const char *params = apreq_params_as_string(r->pool, args, NULL,
APREQ_JOIN_QUOTE);


-Pranil

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message