Re: input filters with mod_ext_filter [patch]

2003-07-08 Thread Philipp Reisner
Hi Jeff,

I recognized now that there were still some deficiencies in the
patch you applied. Where can I get the (your) current version 
of that file, so that I can send you the next patch. --
Of course with detailed description what I needed to modify.

-Philipp

Am Dienstag, 1. Juli 2003 13:27 schrieb Jeff Trawick:
 finally committed, sorry for the delay, thanks again for your contribution!

 I made some minor formatting changes to your final patch as well as a
 code change to an area you were concerned about.

 Philipp Reisner wrote:
  Am Montag, 23. Juni 2003 03:56 schrieb Jeff Trawick:
 
  BTW, Please have a close look to the part where I look at the
  Content-Type header. The old code examien r-content_type. I had to
  find an other way, one that is also possible for request filtering...

 r-content_type is set in cases where the Content-Type header in
 r-headers_out is not accurate

 For input filters I left the checking for Content-Type alone, but for
 output filters I changed it back to the way it worked previously.  The
 code is not as pretty as yours, but as ap_set_content_type() does not
 bother to fill in r-headers_out, the difference is necessary.

 from your patch:
  -if (!f-r-content_type) {
  -ctx-noop = 1;
  -}
  -else {
  -const char *ctypes = f-r-content_type;
  -const char *ctype = ap_getword(f-r-pool, ctypes, ';');
  -
  -if (strcasecmp(ctx-filter-intype, ctype)) {
  -/* wrong IMT for us; don't mess with the output */
  -ctx-noop = 1;
  -}
  -}
  +const char *ctypes = apr_table_get(ctx-filter-mode ==
  INPUT_FILTER ? +  
  f-r-headers_in : f-r-headers_out, +  
  Content-Type);

-- 
: Dipl-Ing Philipp Reisner  Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH  Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austriahttp://www.linbit.com :



Re: input filters with mod_ext_filter [patch]

2003-06-24 Thread Philipp Reisner
Am Montag, 23. Juni 2003 19:02 schrieben Sie:
 On Mon, Jun 23, 2003 at 10:26:55AM +0200, Philipp Reisner wrote:
  Am Montag, 23. Juni 2003 03:56 schrieb Jeff Trawick:
   (apologies for missing the right mail reference and nasty quoting...
   e-mail problems, and luckily I was browsing the archives on daedalus
   during my ISP-imposed silence)
  
   Philip,
  
   Thanks for submitting the patch.  I hope you will fix minor issues and
   resubmit for further review?
 
  Hi Jeff,
 
  Of course! I am happy that you are willing to help me to get it in.
 
  Please find the new version of the patch attached.
 
  BTW, Please have a close look to the part where I look at the
  Content-Type header. The old code examien r-content_type. I had to
  find an other way, one that is also possible for request filtering...

 You removed
 -apr_bucket_brigade *bb;
 so the later
  APR_BRIGADE_INSERT_TAIL(bb, b);
 is going to fail, won't it?

 Cheers,
 Glenn


 @@ -658,7 +662,6 @@
  apr_size_t len;
  char buf[4096];
  apr_status_t rv;
 -apr_bucket_brigade *bb;
  apr_bucket *b;

  while (1) {
 @@ -675,14 +678,9 @@
  if (rv != APR_SUCCESS) {
  return rv;
  }
 -bb = apr_brigade_create(r-pool, c-bucket_alloc);
 -b = apr_bucket_transient_create(buf, len, c-bucket_alloc);
 +b = apr_bucket_heap_create(buf, len, NULL, c-bucket_alloc);
  APR_BRIGADE_INSERT_TAIL(bb, b);
 -if ((rv = ap_pass_brigade(f-next, bb)) != APR_SUCCESS) {
 -ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
 -  ap_pass_brigade());
 -return rv;
 -}
 +return APR_SUCCESS;
  }
  /* we should never get here; if we do, a bogus error message would be
   * the least of our problems


Have a look at the chunk before, there the function gets a new parameter
called bb.  

-Philipp

-- 
: Dipl-Ing Philipp Reisner  Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH  Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austriahttp://www.linbit.com :



headers for an input filter in AP_FTYPE_CONNECTION mode ?

2003-06-24 Thread Philipp Reisner
Hi,

Now since I can do input (request) filtering with mod_ext_filter,
I tried to set ftype = AP_FTYPE_CONNECTION and expected to get
the headers. If you set ftype to AP_FTYPE_CONNECTION on an output
filter, it will get the complete response including headers.

I have to add that I deployed my input filter on a name based 
vhost. -- Does anyone know it if does work with an IP based
vhost ?

TIA
-Philipp
-- 
: Dipl-Ing Philipp Reisner  Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH  Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austriahttp://www.linbit.com :



Re: input filters with mod_ext_filter [patch]

2003-06-23 Thread Philipp Reisner
Am Montag, 23. Juni 2003 03:56 schrieb Jeff Trawick:
 (apologies for missing the right mail reference and nasty quoting...
 e-mail problems, and luckily I was browsing the archives on daedalus
 during my ISP-imposed silence)

 Philip,

 Thanks for submitting the patch.  I hope you will fix minor issues and
 resubmit for further review?

Hi Jeff,

Of course! I am happy that you are willing to help me to get it in.

Please find the new version of the patch attached.

BTW, Please have a close look to the part where I look at the Content-Type
header. The old code examien r-content_type. I had to find an other
way, one that is also possible for request filtering...

-Philipp
-- 
: Dipl-Ing Philipp Reisner  Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH  Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austriahttp://www.linbit.com :
--- mod_ext_filter.c_orig	2003-02-27 13:33:07.0 +0100
+++ mod_ext_filter.c	2003-06-23 10:22:07.0 +0200
@@ -117,6 +117,9 @@
 static const server_rec *main_server;
 
 static apr_status_t ef_output_filter(ap_filter_t *, apr_bucket_brigade *);
+static apr_status_t ef_input_filter(ap_filter_t *, apr_bucket_brigade *, 
+ap_input_mode_t, apr_read_type_e, 
+apr_off_t);
 
 #define DBGLVL_SHOWOPTIONS 1
 #define DBGLVL_ERRORCHECK  2
@@ -351,12 +354,10 @@
 /* XXX need a way to ensure uniqueness among all filters */
 ap_register_output_filter(filter-name, ef_output_filter, NULL, filter-ftype);
 }
-#if 0  /* no input filters yet */
 else if (filter-mode == INPUT_FILTER) {
 /* XXX need a way to ensure uniqueness among all filters */
-ap_register_input_filter(filter-name, ef_input_filter, NULL, AP_FTYPE_RESOURCE);
+ap_register_input_filter(filter-name, ef_input_filter, NULL, filter-ftype);
 }
-#endif
 else {
 ap_assert(1 != 1); /* we set the field wrong somehow */
 }
@@ -592,18 +593,20 @@
 ctx-p = f-r-pool;
 if (ctx-filter-intype 
 ctx-filter-intype != INTYPE_ALL) {
-if (!f-r-content_type) {
-ctx-noop = 1;
-}
-else {
-const char *ctypes = f-r-content_type;
-const char *ctype = ap_getword(f-r-pool, ctypes, ';');
-
-if (strcasecmp(ctx-filter-intype, ctype)) {
-/* wrong IMT for us; don't mess with the output */
-ctx-noop = 1;
-}
-}
+const char *ctypes = apr_table_get(ctx-filter-mode == INPUT_FILTER ?
+   f-r-headers_in : f-r-headers_out,
+   Content-Type);
+	if(ctypes) {
+	const char *ctype = ap_getword(f-r-pool, ctypes, ';');
+
+	if (strcasecmp(ctx-filter-intype, ctype)) {
+		/* wrong IMT for us; don't mess with the output */
+		ctx-noop = 1;
+	}
+	} 
+	else {
+	ctx-noop = 1;
+	}
 }
 if (ctx-filter-enable_env 
 !apr_table_get(f-r-subprocess_env, ctx-filter-enable_env)) {
@@ -646,10 +649,11 @@
 
 /* drain_available_output(): 
  *
- * if any data is available from the filter, read it and pass it
- * to the next filter
+ * if any data is available from the filter, read it and append it
+ * to the the bucket brigade
  */
-static apr_status_t drain_available_output(ap_filter_t *f)
+static apr_status_t drain_available_output(ap_filter_t *f,
+   apr_bucket_brigade *bb)
 {
 request_rec *r = f-r;
 conn_rec *c = r-connection;
@@ -658,7 +662,6 @@
 apr_size_t len;
 char buf[4096];
 apr_status_t rv;
-apr_bucket_brigade *bb;
 apr_bucket *b;
 
 while (1) {
@@ -675,14 +678,9 @@
 if (rv != APR_SUCCESS) {
 return rv;
 }
-bb = apr_brigade_create(r-pool, c-bucket_alloc);
-b = apr_bucket_transient_create(buf, len, c-bucket_alloc);
+b = apr_bucket_heap_create(buf, len, NULL, c-bucket_alloc);
 APR_BRIGADE_INSERT_TAIL(bb, b);
-if ((rv = ap_pass_brigade(f-next, bb)) != APR_SUCCESS) {
-ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-  ap_pass_brigade());
-return rv;
-}
+return APR_SUCCESS;
 }
 /* we should never get here; if we do, a bogus error message would be
  * the least of our problems 
@@ -691,7 +689,7 @@
 }
 
 static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data, 
-apr_size_t len)
+apr_size_t len, apr_bucket_brigade *bb)
 {
 ef_ctx_t *ctx = f-ctx;
 ef_dir_t *dc = ctx-dc;
@@ -716,7 +714,7 @@
  * to read data from the child process and pass it down to the
  * next filter!
  */
-rv = drain_available_output(f);
+rv = drain_available_output(f, bb

input filters with mod_ext_filter [patch]

2003-06-22 Thread Philipp Reisner
Hi,

I guess I do not need to tell you that input filters with mod_ext_filter
were not implemented. Since I needed this feature I implemented it.

It would be a great honour for me if you would apply this patch to the 
main tree.

-Philipp--- mod_ext_filter.c	Thu Feb 27 13:33:07 2003
+++ mod_ext_filter.c_enh	Sun Jun 22 10:30:45 2003
@@ -58,6 +58,10 @@
 
 /*
  * mod_ext_filter allows Unix-style filters to filter http content.
+ * 
+ * Support for input filters added by Philipp Reisner in June 2003.
+ * 
+ * apxs2 -Wc,-Wall,-g -Wl,-g -c -i mod_ext_filter.c
  */
 
 #include httpd.h
@@ -124,6 +128,11 @@
 
 #define ERRFN_USERDATA_KEY EXTFILTCHILDERRFN
 
+static int ef_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, 
+   ap_input_mode_t mode, apr_read_type_e block,
+   apr_off_t readbytes);
+
+
 static void *create_ef_dir_conf(apr_pool_t *p, char *dummy)
 {
 ef_dir_t *dc = (ef_dir_t *)apr_pcalloc(p, sizeof(ef_dir_t));
@@ -351,12 +360,12 @@
 /* XXX need a way to ensure uniqueness among all filters */
 ap_register_output_filter(filter-name, ef_output_filter, NULL, filter-ftype);
 }
-#if 0  /* no input filters yet */
+  /* no input filters yet */
 else if (filter-mode == INPUT_FILTER) {
 /* XXX need a way to ensure uniqueness among all filters */
 ap_register_input_filter(filter-name, ef_input_filter, NULL, AP_FTYPE_RESOURCE);
 }
-#endif
+
 else {
 ap_assert(1 != 1); /* we set the field wrong somehow */
 }
@@ -590,20 +599,24 @@
 return APR_EINVAL;
 }
 ctx-p = f-r-pool;
+
 if (ctx-filter-intype 
 ctx-filter-intype != INTYPE_ALL) {
-if (!f-r-content_type) {
-ctx-noop = 1;
-}
-else {
-const char *ctypes = f-r-content_type;
-const char *ctype = ap_getword(f-r-pool, ctypes, ';');
-
-if (strcasecmp(ctx-filter-intype, ctype)) {
-/* wrong IMT for us; don't mess with the output */
-ctx-noop = 1;
-}
-}
+	const char *ctypes = apr_table_get(ctx-filter-mode == INPUT_FILTER ?
+	   f-r-headers_in : f-r-headers_out,
+	   Content-Type);
+	const char *ctype = ap_getword(f-r-pool, ctypes, ';');
+	
+	if (strcasecmp(ctx-filter-intype, ctype)) {
+	/* wrong IMT for us; don't mess with the output */
+	ctx-noop = 1;
+	}
+	
+	ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, f-r,
+  filter '%s': Content-Type='%s' = %s,
+		  ctx-filter-name, ctype,
+		  ctx-noop == 1 ? noop : apply);
+
 }
 if (ctx-filter-enable_env 
 !apr_table_get(f-r-subprocess_env, ctx-filter-enable_env)) {
@@ -646,10 +659,10 @@
 
 /* drain_available_output(): 
  *
- * if any data is available from the filter, read it and pass it
- * to the next filter
+ * if any data is available from the filter, read it and append it
+ * to the the bucket brigade
  */
-static apr_status_t drain_available_output(ap_filter_t *f)
+static apr_status_t drain_available_output(ap_filter_t *f,apr_bucket_brigade *bb)
 {
 request_rec *r = f-r;
 conn_rec *c = r-connection;
@@ -658,7 +671,6 @@
 apr_size_t len;
 char buf[4096];
 apr_status_t rv;
-apr_bucket_brigade *bb;
 apr_bucket *b;
 
 while (1) {
@@ -675,14 +687,9 @@
 if (rv != APR_SUCCESS) {
 return rv;
 }
-bb = apr_brigade_create(r-pool, c-bucket_alloc);
-b = apr_bucket_transient_create(buf, len, c-bucket_alloc);
+b = apr_bucket_heap_create(buf, len, NULL, c-bucket_alloc);
 APR_BRIGADE_INSERT_TAIL(bb, b);
-if ((rv = ap_pass_brigade(f-next, bb)) != APR_SUCCESS) {
-ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-  ap_pass_brigade());
-return rv;
-}
+	return APR_SUCCESS;
 }
 /* we should never get here; if we do, a bogus error message would be
  * the least of our problems 
@@ -691,7 +698,7 @@
 }
 
 static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data, 
-apr_size_t len)
+apr_size_t len,apr_bucket_brigade *bb)
 {
 ef_ctx_t *ctx = f-ctx;
 ef_dir_t *dc = ctx-dc;
@@ -716,7 +723,7 @@
  * to read data from the child process and pass it down to the
  * next filter!
  */
-rv = drain_available_output(f);
+rv = drain_available_output(f,bb);
 if (APR_STATUS_IS_EAGAIN(rv)) {
 #if APR_FILES_AS_SOCKETS
 int num_events;
@@ -750,7 +757,14 @@
 return rv;
 }
 
-static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
+/* ef_unified_filter: 
+ *
+ * runs the bucket brigade bb through the filter and returns the 
+ * and puts the result into bb. Dropping the previous content
+ * of bb (the input)
+ */
+
+static int