summaryrefslogtreecommitdiff
path: root/modules/metadata
diff options
context:
space:
mode:
authorRainer Jung <rjung@apache.org>2012-07-25 21:29:15 +0000
committerRainer Jung <rjung@apache.org>2012-07-25 21:29:15 +0000
commit100579491945dc00a9655435144ef24eb124e380 (patch)
treee3833cb1dcaa28a4d3c7a1ed43fc1f6879051e0a /modules/metadata
parent7cbad3ad2a2cb6ad3e3771766b14cf527607c794 (diff)
downloadhttpd-100579491945dc00a9655435144ef24eb124e380.tar.gz
mod_setenvif: Compile the regex used by is_header_regex() only once
during startup This should save some memory, especially with .htaccess Backport of r1343099. Submitted by: sf Reviewed by: rjung, jim Backported by: rjung git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1365774 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/metadata')
-rw-r--r--modules/metadata/mod_setenvif.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/metadata/mod_setenvif.c b/modules/metadata/mod_setenvif.c
index 80825ccefa..65214cd4f0 100644
--- a/modules/metadata/mod_setenvif.c
+++ b/modules/metadata/mod_setenvif.c
@@ -165,17 +165,15 @@ static void *merge_setenvif_config(apr_pool_t *p, void *basev, void *overridesv)
#define ICASE_MAGIC ((void *)(&setenvif_module))
#define SEI_MAGIC_HEIRLOOM "setenvif-phase-flag"
+static ap_regex_t *is_header_regex_regex;
+
static int is_header_regex(apr_pool_t *p, const char* name)
{
/* If a Header name contains characters other than:
* -,_,[A-Z\, [a-z] and [0-9].
* assume the header name is a regular expression.
*/
- ap_regex_t *preg = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
- (AP_REG_EXTENDED | AP_REG_NOSUB ));
- ap_assert(preg != NULL);
-
- if (ap_regexec(preg, name, 0, NULL, 0)) {
+ if (ap_regexec(is_header_regex_regex, name, 0, NULL, 0)) {
return 1;
}
@@ -633,6 +631,10 @@ static void register_hooks(apr_pool_t *p)
{
ap_hook_header_parser(match_headers, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_post_read_request(match_headers, NULL, NULL, APR_HOOK_MIDDLE);
+
+ is_header_regex_regex = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
+ (AP_REG_EXTENDED | AP_REG_NOSUB ));
+ ap_assert(is_header_regex_regex != NULL);
}
AP_DECLARE_MODULE(setenvif) =