Skip to content

Instantly share code, notes, and snippets.

@yteraoka
Created March 6, 2013 10:27
Show Gist options
  • Save yteraoka/5098379 to your computer and use it in GitHub Desktop.
Save yteraoka/5098379 to your computer and use it in GitHub Desktop.
特定の Response Header の値を環境変数にコピーして Header を削除する機能を mod_headers に追加する patch for Apache 2.4.4
diff -uNr httpd-2.4.4.orig/modules/metadata/mod_headers.c httpd-2.4.4/modules/metadata/mod_headers.c
--- httpd-2.4.4.orig/modules/metadata/mod_headers.c 2012-12-09 22:20:13.000000000 +0900
+++ httpd-2.4.4/modules/metadata/mod_headers.c 2013-02-27 19:37:08.466361782 +0900
@@ -96,7 +96,8 @@
hdr_unset = 'u', /* unset header */
hdr_echo = 'e', /* echo headers from request to response */
hdr_edit = 'r', /* change value by regexp, match once */
- hdr_edit_r = 'R' /* change value by regexp, everymatch */
+ hdr_edit_r = 'R', /* change value by regexp, everymatch */
+ hdr_toenv = 'E' /* copy to subprocess_env and unset */
} hdr_actions;
/*
@@ -439,6 +440,8 @@
new->action = hdr_merge;
else if (!strcasecmp(action, "unset"))
new->action = hdr_unset;
+ else if (!strcasecmp(action, "toenv"))
+ new->action = hdr_toenv;
else if (!strcasecmp(action, "echo"))
new->action = hdr_echo;
else if (!strcasecmp(action, "edit"))
@@ -447,7 +450,7 @@
new->action = hdr_edit_r;
else
return "first argument must be 'add', 'set', 'append', 'merge', "
- "'unset', 'echo', 'edit', or 'edit*'.";
+ "'unset', 'toenv', 'echo', 'edit', or 'edit*'.";
if (new->action == hdr_edit || new->action == hdr_edit_r) {
if (subs == NULL) {
@@ -758,6 +761,11 @@
case hdr_unset:
apr_table_unset(headers, hdr->header);
break;
+ case hdr_toenv:
+ apr_table_add(r->subprocess_env, process_tags(hdr, r),
+ apr_table_get(headers, hdr->header));
+ apr_table_unset(headers, hdr->header);
+ break;
case hdr_echo:
v.r = r;
v.hdr = hdr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment