httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pranesh Vadhirajan" <>
Subject RE: Reading content of requests entering Apache
Date Tue, 10 Jan 2012 15:54:34 GMT
     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;


-----Original Message-----
From: Nick Kew [] 
Sent: Monday, January 09, 2012 10:52 AM
Subject: Re: Reading content of requests entering Apache

On Mon, 9 Jan 2012 10:33:53 -0500
"Pranesh Vadhirajan" <> wrote:

> Hello All,
>      I would like to know how to be able to read the content of the
> 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

I could also recommend the book: see

Nick Kew

View raw message