Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Dev

Accessing POST request body from a module

 

 

Apache dev RSS feed   Index | Next | Previous | View Threaded


spam_from_apache_dev at chezphil

Feb 2, 2006, 2:45 PM

Post #1 of 5 (2216 views)
Permalink
Accessing POST request body from a module

Dear All,

I am porting some CGI code to run as a module. It is all pretty
straightforward, except that I can't work out how to get at a POST
request's body. The CGI code reads from stdin, which doesn't seem to be
the right thing to do in the module. I'm probably missing something
obvious; maybe I'm not searching for the right keywords. Can someone
point me in the right direction?

Many Thanks,

--Phil.


nick at webthing

Feb 2, 2006, 4:56 PM

Post #2 of 5 (2061 views)
Permalink
Re: Accessing POST request body from a module [In reply to]

On Thursday 02 February 2006 22:45, Phil Endecott wrote:
> [chop]

If you had a usable-looking email address. I could reply with
exactly what you need, from something that's not currently
available on a public mailinglist.

--
Nick Kew


mv at binarysec

Feb 2, 2006, 9:43 PM

Post #3 of 5 (2068 views)
Permalink
Re: Accessing POST request body from a module [In reply to]

Hello,

With something like that :
while (ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES,
APR_BLOCK_READ, len) == APR_SUCCESS) {
apr_brigade_flatten(brigade, buf, &len);
apr_brigade_cleanup(brigade);
tlen += len;
if (tlen == count_bytes || !len) {
break;
}
buf += len;
len = count_bytes - tlen;
}


----- Original Message -----
From: "Phil Endecott" <spam_from_apache_dev[at]chezphil.org>
To: <dev[at]httpd.apache.org>
Sent: Thursday, February 02, 2006 11:45 PM
Subject: Accessing POST request body from a module


> Dear All,
>
> I am porting some CGI code to run as a module. It is all pretty
> straightforward, except that I can't work out how to get at a POST
> request's body. The CGI code reads from stdin, which doesn't seem to be
> the right thing to do in the module. I'm probably missing something
> obvious; maybe I'm not searching for the right keywords. Can someone
> point me in the right direction?
>
> Many Thanks,
>
> --Phil.
>
>


spam_from_apache_dev at chezphil

Feb 3, 2006, 12:26 PM

Post #4 of 5 (2071 views)
Permalink
Re: Accessing POST request body from a module [In reply to]

>> I am porting some CGI code to run as a module. It is all pretty
>> straightforward, except that I can't work out how to get at a POST
>> request's body.

Thanks to Michael for this:

> while (ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES,
> APR_BLOCK_READ, len) == APR_SUCCESS) {
> apr_brigade_flatten(brigade, buf, &len);
> apr_brigade_cleanup(brigade);
> tlen += len;
> if (tlen == count_bytes || !len) {
> break;
> }
> buf += len;
> len = count_bytes - tlen;
> }

That looks good and I've tried something like it, but it seems to
segfault as soon as ap_get_brigade is called. I'm guessing that I need
to create the brigade first, but apr_brigade_create has a second
mysterious parameter that I can't work out. Michael, maybe you just
need to post the five lines before those??

BTW, is there any better documentation for this than
http://docx.webperf.org/group__APR__Util__Bucket__Brigades.html?

Nick Kew wrote:

> If you had a usable-looking email address. I could reply with
> exactly what you need

I'm sorry that it doesn't look useable to you, but I can assure you that
it does work; it's not even filtered. It would be quite hard to
subscribe to this list with a non-functioning address, I think.

Regards,

--Phil.


mv at binarysec

Feb 4, 2006, 2:24 AM

Post #5 of 5 (2075 views)
Permalink
Re: Accessing POST request body from a module [In reply to]

Hi Phil,

At the request_handler time you may create the brigade with something like
this :
<snip>
brigade = apr_brigade_create(r->pool, r->connection->bucket_alloc);
</snip>

----- Original Message -----
From: "Phil Endecott" <spam_from_apache_dev[at]chezphil.org>
To: <dev[at]httpd.apache.org>
Sent: Friday, February 03, 2006 9:26 PM
Subject: Re: Accessing POST request body from a module


> >> I am porting some CGI code to run as a module. It is all pretty
> >> straightforward, except that I can't work out how to get at a POST
> >> request's body.
>
> Thanks to Michael for this:
>
> > while (ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES,
> > APR_BLOCK_READ, len) == APR_SUCCESS) {
> > apr_brigade_flatten(brigade, buf, &len);
> > apr_brigade_cleanup(brigade);
> > tlen += len;
> > if (tlen == count_bytes || !len) {
> > break;
> > }
> > buf += len;
> > len = count_bytes - tlen;
> > }
>
> That looks good and I've tried something like it, but it seems to segfault
> as soon as ap_get_brigade is called. I'm guessing that I need to create
> the brigade first, but apr_brigade_create has a second mysterious
> parameter that I can't work out. Michael, maybe you just need to post the
> five lines before those??
>
> BTW, is there any better documentation for this than
> http://docx.webperf.org/group__APR__Util__Bucket__Brigades.html?
>
> Nick Kew wrote:
>
> > If you had a usable-looking email address. I could reply with
> > exactly what you need
>
> I'm sorry that it doesn't look useable to you, but I can assure you that
> it does work; it's not even filtered. It would be quite hard to subscribe
> to this list with a non-functioning address, I think.
>
> Regards,
>
> --Phil.
>
>
>

Apache dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.