httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Verdelli <christian.verde...@zeropiu.it>
Subject Input Filter reading Body
Date Fri, 20 Oct 2006 15:03:04 GMT


-
-- Hi,

im writing my first simple input filters ; i need it to debug the  
request body (content of POST) coming to my Web Server before is handled
by a third party contect handler module (which corrupt data).
I simply want to print out the content of the body request sent by  
the client . I wrote this peace of code:



static int redirect_wmlInFilter (ap_filter_t* f, apr_bucket_brigade*  
brigade,
ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes) {

apr_bucket* bucket ;
apr_status_t ret ;

if ( ret = ap_get_brigade(f->next, brigade, mode, block, readbytes) ,
ret == APR_SUCCESS )
for ( bucket = APR_BRIGADE_FIRST(brigade) ;
bucket != APR_BRIGADE_SENTINEL(brigade) ;
bucket = APR_BUCKET_NEXT(bucket) )

char *data[bucket->length];
int len;
apr_bucket_read(bucket,&data,&len,1);
ap_log_perror(APLOG_MARK, APLOG_NOTICE, NULL, f->c->pool,
"(IN) %s %s: %d bytes - %s ", f->frec->name, t, bucket->length , data );

else
ap_log_perror(APLOG_MARK, APLOG_NOTICE, NULL, f->c->pool,
"(IN) %s: ap_get_brigade returned %d", f->frec->name, ret) ;

return ret ;
}


The filter is then registered as input filter in the  
AP_FTYPE_TRANSCODE phase.

static void redirect_wmlRegisterHooks(apr_pool_t *p) {
ap_register_input_filter 
(webifilter,redirect_wmlInFilter,ifilter_init, AP_FTYPE_TRANSCODE );
}



To test it i simply post fake data with using curl : curl -v -d  
nameb=valueb http://myserver.myhost.com/postread.cgi

Looking at the logs the instead of seeing the content body  
nameb=valueb , here what i get :

[Fri Oct 20 00:42:40 2006] [notice] (IN)\twebicookiet20 bytes - \x01 
\x8b\xa7\x1b




Maybe should i decode it before print it ??
Any suggestion will be appreciated

-- 




Mime
View raw message