summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/c-modules/client_add_filter/mod_client_add_filter.c
diff options
context:
space:
mode:
Diffstat (limited to 'debian/perl-framework/c-modules/client_add_filter/mod_client_add_filter.c')
-rw-r--r--debian/perl-framework/c-modules/client_add_filter/mod_client_add_filter.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/debian/perl-framework/c-modules/client_add_filter/mod_client_add_filter.c b/debian/perl-framework/c-modules/client_add_filter/mod_client_add_filter.c
new file mode 100644
index 0000000..ce5ef99
--- /dev/null
+++ b/debian/perl-framework/c-modules/client_add_filter/mod_client_add_filter.c
@@ -0,0 +1,54 @@
+#define HTTPD_TEST_REQUIRE_APACHE 2
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_protocol.h"
+#include "http_request.h"
+#include "http_log.h"
+#include "ap_config.h"
+
+/*
+ * in real life we'd never allow the client to configure filters.
+ * the purpose of this module is to let .t tests configure filters
+ * this allows to test non-filtered and filtered requests without
+ * duplicating lots of test configuration
+ */
+
+static int client_add_filter_header(void *data,
+ const char *key,
+ const char *val)
+{
+ request_rec *r = (request_rec *)data;
+
+ if (strcasecmp(key, "X-AddInputFilter") == 0) {
+ ap_add_input_filter(val, NULL, r, r->connection);
+ }
+ else if (strcasecmp(key, "X-AddOutputFilter") == 0) {
+ ap_add_output_filter(val, NULL, r, r->connection);
+ }
+
+ return 1;
+}
+
+static void client_add_filter_insert(request_rec *r)
+{
+ apr_table_do(client_add_filter_header, (void*)r,
+ r->headers_in, NULL);
+}
+
+static void client_add_filter_register_hooks(apr_pool_t *p)
+{
+ ap_hook_insert_filter(client_add_filter_insert,
+ NULL, NULL, APR_HOOK_LAST);
+}
+
+module AP_MODULE_DECLARE_DATA client_add_filter_module = {
+ STANDARD20_MODULE_STUFF,
+ NULL, /* create per-dir config structures */
+ NULL, /* merge per-dir config structures */
+ NULL, /* create per-server config structures */
+ NULL, /* merge per-server config structures */
+ NULL, /* table of config file commands */
+ client_add_filter_register_hooks /* register hooks */
+};
+