httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Varanasi, Sasikala" <Sasikala.Varan...@sabre-holdings.com>
Subject Apache Input Filter
Date Tue, 31 Aug 2010 14:34:55 GMT
Hi,
 
I have a need to capture the incoming request body each time a request
comes into Apache Proxy server. I have mod_proxy and mod_filters setup
and I have an input filter that I wrote that captures the payload from
the request and logs it out. The input filter is able to do this,
however, the filter is processing the same request twice. The input
filter gets invoked 7-8 times for each request, most of the time with
empty buf on apr_bucket_read and twice with the same request contents.
What do I need to do to change the filter not to process the request
contents twice? How do I know the request has been already processed
once? Here is the part of the code that I have in the filter. Anything
that I missed? thank you in advance for your help.
 
if (ap_is_initial_req(r)) {
   if ( ret = ap_get_brigade(f->next, bb, mode, block, nbytes), ret ==
APR_SUCCESS ) {
    const char* buf;
    for ( b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b =
APR_BUCKET_NEXT(b) )
    {
 

                   int len;
                   if (apr_bucket_read(b,&buf,&bytes,APR_NONBLOCK_READ)
== APR_SUCCESS) {
                              read = 1;
                   }
 
    }
 
    //if anything is read, send out the payload
    if (read == 1) {
     //check if buf is all empty
     char *newbuf = stripspaces(buf);
     int l = strlen(newbuf);
    
 

     if (l == 0 || l == 1) {
 
                fprintf(stderr, "the buf length is 0 or 1 - all empty!
not sending data \n");
     } else   {
     
                fprintf(stderr, "unparsed uri is: %s \n",
r->unparsed_uri);
 
    
                fprintf(stderr, "The request buf is --------------- %s",
buf);
     
   }
   }
     }
  }
  return ret ;

Mime
View raw message