Author: jfrederic.clere(a)jboss.com
Date: 2008-04-23 05:11:49 -0400 (Wed, 23 Apr 2008)
New Revision: 1556
Modified:
sandbox/httpd_filters/README
sandbox/httpd_filters/cookie_filter.c
Log:
mod_jk (for example) doesn't call the inputfilter so use the ouputfilter to dump the
input headers too.
Modified: sandbox/httpd_filters/README
===================================================================
--- sandbox/httpd_filters/README 2008-04-22 17:13:40 UTC (rev 1555)
+++ sandbox/httpd_filters/README 2008-04-23 09:11:49 UTC (rev 1556)
@@ -10,3 +10,7 @@
SetOutputFilter COOKIE_FILTER_OUT
SetInputFilter COOKIE_FILTER_IN
+++
+Notes:
+* The COOKIE_FILTER_OUT prints also the input headers so probably you only need this
one.
+* The output is truncated a 127 bytes.
+* The output goes in the error_log file.
Modified: sandbox/httpd_filters/cookie_filter.c
===================================================================
--- sandbox/httpd_filters/cookie_filter.c 2008-04-22 17:13:40 UTC (rev 1555)
+++ sandbox/httpd_filters/cookie_filter.c 2008-04-23 09:11:49 UTC (rev 1556)
@@ -24,19 +24,26 @@
#include "http_protocol.h"
#include "http_core.h"
-static int echo_header_in(request_rec *v, const char *key, const char *val)
+static int echo_header(request_rec *v, const char *key, const char *val, const char
*param)
{
+ char buf[128];
+ strncpy(buf, val, 128);
+ buf[127] = '\0';
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, v,
- "Got(in): %s : %s", key, val);
+ "Got(%s): %s : size: %d value: %s", param, key, strlen(val),
buf);
return 1;
}
-static int echo_header_out(request_rec *v, const char *key, const char *val)
+
+static int echo_header_in(request_rec *v, const char *key, const char *val)
{
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, v,
- "Got(out): %s : %s", key, val);
- return 1;
+ return(echo_header(v, key, val, "in"));
}
+static int echo_header_ou(request_rec *v, const char *key, const char *val)
+{
+ return(echo_header(v, key, val, "ou"));
+}
+
static apr_status_t in_filter(ap_filter_t *f, apr_bucket_brigade *in,
ap_input_mode_t mode,
apr_read_type_e block,
@@ -50,8 +57,12 @@
static apr_status_t out_filter(ap_filter_t *f, apr_bucket_brigade *in)
{
+ /* Dump the received headers */
apr_table_do((int (*) (void *, const char *, const char *))
- echo_header_out, (void *) f->r, f->r->headers_out,
NULL);
+ echo_header_in, (void *) f->r, f->r->headers_in,
NULL);
+ /* Dump the output headers */
+ apr_table_do((int (*) (void *, const char *, const char *))
+ echo_header_ou, (void *) f->r, f->r->headers_out,
NULL);
ap_remove_output_filter(f);
return ap_pass_brigade(f->next,in);
}