Hi,
I just realized that Joe had already developed something similar
in httpd-2.1. The only difference was in the function names - I changed
his patch a little (to match httpd-2.0), and here it is..
-Madhu
Index: mod_headers.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_headers.c,v
retrieving revision 1.42.2.5
diff -u -r1.42.2.5 mod_headers.c
--- mod_headers.c 24 Apr 2004 11:51:07 -0000 1.42.2.5
+++ mod_headers.c 14 May 2004 16:41:30 -0000
@@ -128,6 +128,14 @@
apr_array_header_t *fixup_out;
} headers_conf;
+/* Pointer to ssl_var_lookup, if available. */
+APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup,
+ (apr_pool_t *, server_rec *,
+ conn_rec *, request_rec *,
+ char *));
+static APR_OPTIONAL_FN_TYPE(ssl_var_lookup) *header_ssl_lookup = NULL;
+static const char *header_request_ssl_var(request_rec *r, char *name);
+
module AP_MODULE_DECLARE_DATA headers_module;
/*
@@ -149,12 +157,29 @@
static const char *header_request_env_var(request_rec *r, char *a)
{
const char *s = apr_table_get(r->subprocess_env,a);
+ if (s == NULL) {
+ s = header_request_ssl_var(r, a);
+ }
if (s)
return s;
else
return "(null)";
}
+static const char *header_request_ssl_var(request_rec *r, char *name)
+{
+ if (header_ssl_lookup) {
+ const char *val = header_ssl_lookup(r->pool, r->server,
+ r->connection, r, name);
+ if (val && val[0])
+ return val;
+ else
+ return "(null)";
+ }
+ else {
+ return "(null)";
+ }
+}
/*
* Config routines
*/
@@ -573,9 +598,17 @@
return OK;
}
+static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
+ apr_pool_t *ptemp, server_rec *s)
+{
+ header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
+ return OK;
+}
+
static void register_hooks(apr_pool_t *p)
{
ap_hook_pre_config(header_pre_config,NULL,NULL,APR_HOOK_MIDDLE);
+ ap_hook_post_config(header_post_config,NULL,NULL,APR_HOOK_MIDDLE);
ap_hook_insert_filter(ap_headers_insert_output_filter, NULL, NULL,
APR_HOOK_LAST);
ap_hook_fixups(ap_headers_fixup, NULL, NULL, APR_HOOK_LAST);
ap_register_output_filter("FIXUP_HEADERS_OUT",
ap_headers_output_filter,