hello sir .. i am student of final computer science and engg .. i read the whole apache server code and understand the concepts .. i want to submit also apache documets to open source community which i prepare for that but sir i have one problem regarding filter inmplentation here.. plz send me correct solution for that ..
the problem is follows as :
i write one filter module just for appending string to html document what ever i request in brower . i compiled my code successfully , install and added by using
apxs -c -i -a append_module.c on linux platform .
i put one fprintf statment to see the really filter register or not . but sir meg printed in error fiile . that mean it evocks the register_hook but i can't say anything after that what is going to happen with my code . i set httpd.conf file by using SetOutputFilter APPEND in proper way . and also i use AddOutputFilter APPEND .html
but it doesn't works . currently i am planing to write filter to add more functionality in apache . but sir if i fail to run very simple code then how can i proceed for big code .. so sir plz send me correct modification if needed and needed configuration to run this module succssfully i have 2.0.46 distribution ...
here is my code :
#include "apr_strings.h" #include "util_filter.h" #include "http_request.h" #include "http_core.h" #include "http_protocol.h" #include "http_log.h" #include "http_main.h" #include "ap_config.h" #include "http_config.h" #include "httpd.h" #include "apr_general.h" #include "apr_buckets.h" #include "apr_tables.h"
module AP_MODULE_DECLARE_DATA append_module; static int append_filter(ap_filter_t *f, apr_bucket_brigade *bb) { apr_bucket *e, *n; request_rec *r = f->r; conn_rec *c = r->connection; char *date_val; apr_size_t len ; char *buff ; buff=apr_bucket_alloc(len, c->bucket_alloc); buff[0]='v'; buff[1]='i'; buff[2]='s'; buff[3]='h'; buff[4]='a'; buff[5]='l';
fprintf(stderr,"hello vishal , we r now in footer handler "); if(!strncasecmp(f->r->content_type, "text/html", 9)) { e=APR_BRIGADE_LAST(bb); if (APR_BUCKET_IS_EOS(e)) {
n= apr_bucket_pool_create(buff ,len,f->r->pool , f->c->bucket_alloc ); APR_BUCKET_INSERT_BEFORE(e, n); apr_table_unset(f->r->headers_out, "ETag"); apr_table_unset(f->r->headers_out, "Last-Modified"); } } ap_pass_brigade(f->next, bb); return APR_SUCCESS; } static void footer_register_hook(apr_pool_t *p) { fprintf(stderr,"hello vishal , we r now in register hook "); ap_register_output_filter("FOOTERFILTER", footer_filter,NULL, AP_FTYPE_CONTENT_SET); } module AP_MODULE_DECLARE_DATA footer_module = { STANDARD20_MODULE_STUFF, NULL, NULL, NULL, NULL, NULL, append_register_hook };
so sir plz help me ..
vishal ruikar
___________________________________________________ Click below to experience Sooraj R Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik, Abhishek & Kareena http://www.mpkdh.com