httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Whitehead <awhiteh...@nordicedge.se>
Subject Re: Reading content of requests entering Apache
Date Wed, 11 Jan 2012 11:10:36 GMT
Hi Pranesh,

I think you'll find that a GET request doesn't have a body to read.
All the information you can get is in the HTTP Request headers and the
URI/Query String which can be found in the tables and values on the
request_rec structure.

This is a much simpler thing to do that the POST/PUT case you described.

__________________________________________________
Anthony Whitehead
Nordic Edge AB
Mobile: +46 (0)70 227 63 38
Business card: www.nordicedge.se/awhitehead .
Visit us on the web at: www.nordicedge.se .
__________________________________________________

This communication is for use by the intended recipient and contains
information that may be privileged, confidential and exempt from
disclosure or copyrighted under applicable law.  If you are not the
intended recipient, you are hereby formally notified that any
dissemination, use, copying or distribution of this e-mail, in whole
or in part, is strictly prohibited.  Please notify the sender by
return e-mail and delete this e-mail from your system.

Unless explicitly so designated this e-mail does not constitute a
contract offer, a contract amendment, or an acceptance of a contract
offer.

E-mail may be susceptible to data corruption, interception,
unauthorised amendment, tampering and virus, and we do not accept
liability for any such corruption, interception, amendment, tampering
or virus or the consequences thereof.

This e-mail does not constitute a consent to the use of sender's
contact information for direct marketing purposes or for transfers of
data to third parties.
__________________________________________________



On 10 January 2012 19:55, Pranesh Vadhirajan <vadhirajan@teralogics.com> wrote:
> Hello All,
> I realized that the reason that the function doesn't do what I want is that
> I am using the ap_setup_client_block() call in the function, which reads
> client block content for POST or PUT requests.
>
> I am attempting to read the content on a GET request.  Is there an analogous
> function I can use? Or a simple API?
>
> Thanks,
> Pranesh
>
>
> -----Original Message-----
> From: Pranesh Vadhirajan [mailto:vadhirajan@teralogics.com]
> Sent: Tuesday, January 10, 2012 10:55 AM
> To: modules-dev@httpd.apache.org
> Subject: RE: Reading content of requests entering Apache
>
> Hello,
>     When I call the following function from the handler function in my
> module, I expect to see the buffer contain the packet contents when I print
> the buffer.  However I see a null buffer on every request.  Is there a
> certain order that I have to execute my modules?  I have tried to execute it
> in FIRST, MIDDLE and LAST positions.  I have also tried to execute my module
> directly after mod_proxy.  Is there some other issue with this function?
>
> I have tried to look at the mod_deflate module as an example, but I am not
> able to understand it in order to apply its principles here.  So, if it
> would be possible to fix the following function to make it work, that would
> be greatly appreciated.
>
> static int util_read(request_rec *r, const char** rbuf)
> {
>   int rc;
>    if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK) {
>       return rc;
>   }
>    if (ap_should_client_block(r)) {
>       char argsbuffer[HUGE_STRING_LEN];
>      int rsize, len_read, rpos=0;
>      long length = r->remaining;
>      *rbuf = apr_pcalloc(r->pool, length + 1);
>
>       while ((len_read =
>               ap_get_client_block(r, argsbuffer, sizeof(argsbuffer))) > 0)
> {
>
>          if ((rpos + len_read) > length) {
>              rsize = length - rpos;
>          }
>          else {
>              rsize = len_read;
>          }
>          memcpy((char*)*rbuf + rpos, argsbuffer, rsize);
>          rpos += rsize;
>      }
>
>    }
>    fprintf(stderr,"Buffer: %s\n",*rbuf);
>   return rc;
> }
>
> static int my_handler(request_rec* r) {
>        char msg_content[1024] = {'\0'};
>        util_read(r,(const char**)&msg_content);
>        return DECLINED;
> }
>
>
> Thanks,
> Pranesh
>
>
> -----Original Message-----
> From: Nick Kew [mailto:niq@apache.org]
> Sent: Monday, January 09, 2012 10:52 AM
> To: modules-dev@httpd.apache.org
> Subject: Re: Reading content of requests entering Apache
>
> On Mon, 9 Jan 2012 10:33:53 -0500
> "Pranesh Vadhirajan" <vadhirajan@teralogics.com> wrote:
>
>> Hello All,
>>
>>      I would like to know how to be able to read the content of the
> request
>> that Apache receives.
>
> What you describe is called an Input Filter.  There are examples in
> the the standard apache distro: for example, mod_deflate and mod_sed
> offer input filters.  mod_security and mod_ironbee are third-party
> examples.
>
> I could also recommend the book: see http://www.apachetutor.org/
>
>
> --
> Nick Kew

Mime
View raw message