httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <sor...@gmail.com>
Subject Re: How to write apache module in C through which to retrieve POST form data from browser?
Date Thu, 17 Jan 2013 08:23:37 GMT
On 2013-01-17 03:59, Dhiren123 wrote:
>    Samething i put HTML page(GET method) in /www folder  and through my apache
> module i communicate with browser successfully.
>     But when i connect to apache module through POST method  ,that action
> page is not found by the server.
> Actually what happens i donot know or where i make the mistakes .Anybody
> suggest me....


I think there are two methods for getting the POST data, I don't know 
which one is the "correct" one.

1. You write an input filter. (Check the appropriate documentation how 
to write input filters.) You either add it with ap_add_input_filter or 
you use the SetInputFilter directive of the core module. Then the input 
filter executes ap_get_brigade. The "brigade" is a linked list of 
"buckets", i.e. some data holders. You loop through the linked list of 
buckets until you get an EOS bucket (EOS = end-of-stream). Note that the 
brigade that you got may not contain the entire POST data. In this case 
the brigade does not have an EOS bucket and the filter will be called 
several times by apache. In any case the filter might be called several 
times, so write your code accordingly. (I think this is explained in the 
filter tutorial. See the apr_buckets.h header also.)

2. You write a loop in which you call ap_get_client_block. I am not sure 
about the stopping criterion of the loop. You could count the size of 
the data that you read and compare it with Content-Length but this does 
not work in the rare cases in which the POST data is compressed. I don't 
know much about this method, but you can lookup documentation on 
ap_get_client_block.

I hope this helps.

Sorin



Mime
View raw message