Useful extensions...
authorJim Jagielski <jim@apache.org>
Tue, 19 Mar 2013 19:09:40 +0000 (19:09 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 19 Mar 2013 19:09:40 +0000 (19:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1458456 13f79535-47bb-0310-9956-ffa450edef68

include/ap_mmn.h
include/util_filter.h
server/util_filter.c

index 1a6b1417260d69d6d16d7fc221c552959c296eb8..e8b7b5d79c2f36f399db82429041a3bc1d4dfc3c 100644 (file)
  * 20121222.5 (2.5.0-dev)  Add "r" and "must_rebind" to util_ldap_connection_t
  * 20121222.6 (2.5.0-dev)  Add ap_proxy_create_hdrbrgd() and
  *                         ap_proxy_pass_brigade()
+ * 20121222.7 (2.5.0-dev)  Add ap_remove_input|output_filter_byhandle()
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
index 8b3c7a848703ac9efc497c95837d4ec65a0ea20c..5a966074ff862537c63a5acc9c8535b463e68370 100644 (file)
@@ -486,6 +486,25 @@ AP_DECLARE(void) ap_remove_input_filter(ap_filter_t *f);
 
 AP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f);
 
+/**
+ * Remove an input filter from either the request or connection stack
+ * it is associated with.
+ * @param next   The filter stack to search
+ * @param handle The filter handle (name) to remove
+ * @return APR_SUCCESS on removal or error
+ */
+AP_DECLARE(apr_status_t) ap_remove_input_filter_byhandle(ap_filter_t *next,
+                                                         const char *handle);
+/**
+ * Remove an output filter from either the request or connection stack
+ * it is associated with.
+ * @param next   The filter stack to search
+ * @param handle The filter handle (name) to remove
+ * @return APR_SUCCESS on removal or error
+ */
+AP_DECLARE(apr_status_t) ap_remove_output_filter_byhandle(ap_filter_t *next,
+                                                          const char *handle);
+
 /* The next two filters are for abstraction purposes only.  They could be
  * done away with, but that would require that we break modules if we ever
  * want to change our filter registration method.  The basic idea, is that
index 7121eced9e68e21c3f9e2f5b749886c82fcd4c2a..01eb533520470eb65962c5c7b0923b0da9996f13 100644 (file)
@@ -479,6 +479,63 @@ AP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f)
                       &f->c->output_filters);
 }
 
+AP_DECLARE(apr_status_t) ap_remove_input_filter_byhandle(ap_filter_t *next,
+                                                         const char *handle)
+{
+    ap_filter_t *found = NULL;
+    ap_filter_rec_t *filter;
+
+    if (!handle) {
+        return APR_EINVAL;
+    }
+    filter = ap_get_input_filter_handle(handle);
+    if (!filter) {
+        return APR_NOTFOUND;
+    }
+
+    while (next) {
+        if (next->frec == filter) {
+            found = next;
+            break;
+        }
+        next = next->next;
+    }
+    if (found) {
+        ap_remove_input_filter(found);
+        return APR_SUCCESS;
+    }
+    return APR_NOTFOUND;
+}
+
+AP_DECLARE(apr_status_t) ap_remove_output_filter_byhandle(ap_filter_t *next,
+                                                          const char *handle)
+{
+    ap_filter_t *found = NULL;
+    ap_filter_rec_t *filter;
+
+    if (!handle) {
+        return APR_EINVAL;
+    }
+    filter = ap_get_output_filter_handle(handle);
+    if (!filter) {
+        return APR_NOTFOUND;
+    }
+
+    while (next) {
+        if (next->frec == filter) {
+            found = next;
+            break;
+        }
+        next = next->next;
+    }
+    if (found) {
+        ap_remove_output_filter(found);
+        return APR_SUCCESS;
+    }
+    return APR_NOTFOUND;
+}
+
+
 /*
  * Read data from the next filter in the filter stack.  Data should be
  * modified in the bucket brigade that is passed in.  The core allocates the