summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/xml/nginx/changes.xml14
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/http/modules/ngx_http_headers_filter_module.c68
-rw-r--r--src/http/ngx_http_core_module.c1
-rw-r--r--src/http/ngx_http_parse.c1
5 files changed, 74 insertions, 12 deletions
diff --git a/docs/xml/nginx/changes.xml b/docs/xml/nginx/changes.xml
index cf27af24b..eb034be11 100644
--- a/docs/xml/nginx/changes.xml
+++ b/docs/xml/nginx/changes.xml
@@ -9,6 +9,20 @@
<title lang="en">nginx changelog</title>
+<changes ver="0.3.34" date="21.03.2006">
+
+<change type="feature">
+<para lang="ru">
+директива add_header поддерживает переменные.
+</para>
+<para lang="en">
+the "add_header" directive supports the variables.
+</para>
+</change>
+
+</changes>
+
+
<changes ver="0.3.33" date="15.03.2006">
<change type="feature">
diff --git a/src/core/nginx.h b/src/core/nginx.h
index c5842582a..ebd959d44 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VER "nginx/0.3.33"
+#define NGINX_VER "nginx/0.3.34"
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ".oldbin"
diff --git a/src/http/modules/ngx_http_headers_filter_module.c b/src/http/modules/ngx_http_headers_filter_module.c
index b0bd0a5ce..8ced8e024 100644
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -10,9 +10,16 @@
typedef struct {
- time_t expires;
- ngx_str_t cache_control;
- ngx_array_t *headers;
+ ngx_table_elt_t value;
+ ngx_array_t *lengths;
+ ngx_array_t *values;
+} ngx_http_header_val_t;
+
+
+typedef struct {
+ time_t expires;
+ ngx_str_t cache_control;
+ ngx_array_t *headers;
} ngx_http_headers_conf_t;
@@ -92,7 +99,8 @@ ngx_http_headers_filter(ngx_http_request_t *r)
{
size_t len;
ngx_uint_t i;
- ngx_table_elt_t *expires, *cc, **ccp, *h, *out;
+ ngx_table_elt_t *expires, *cc, **ccp, *out;
+ ngx_http_header_val_t *h;
ngx_http_headers_conf_t *conf;
if ((r->headers_out.status != NGX_HTTP_OK
@@ -242,7 +250,20 @@ ngx_http_headers_filter(ngx_http_request_t *r)
return NGX_ERROR;
}
- *out = h[i];
+ out->hash = h[i].value.hash;
+ out->key = h[i].value.key;
+
+ if (h[i].lengths == NULL) {
+ out->value = h[i].value.value;
+ continue;
+ }
+
+ if (ngx_http_script_run(r, &out->value, h[i].lengths->elts, 0,
+ h[i].values->elts)
+ == NULL)
+ {
+ return NGX_ERROR;
+ }
}
}
@@ -368,8 +389,10 @@ ngx_http_headers_add(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_headers_conf_t *hcf = conf;
- ngx_str_t *value;
- ngx_table_elt_t *h;
+ ngx_int_t n;
+ ngx_str_t *value;
+ ngx_http_header_val_t *h;
+ ngx_http_script_compile_t sc;
value = cf->args->elts;
@@ -379,7 +402,8 @@ ngx_http_headers_add(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
if (hcf->headers == NULL) {
- hcf->headers = ngx_array_create(cf->pool, 1, sizeof(ngx_table_elt_t));
+ hcf->headers = ngx_array_create(cf->pool, 1,
+ sizeof(ngx_http_header_val_t));
if (hcf->headers == NULL) {
return NGX_CONF_ERROR;
}
@@ -390,9 +414,31 @@ ngx_http_headers_add(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- h->hash = 1;
- h->key = value[1];
- h->value = value[2];
+ h->value.hash = 1;
+ h->value.key = value[1];
+ h->value.value = value[2];
+ h->lengths = NULL;
+ h->values = NULL;
+
+ n = ngx_http_script_variables_count(&value[2]);
+
+ if (n == 0) {
+ return NGX_CONF_OK;
+ }
+
+ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
+
+ sc.cf = cf;
+ sc.source = &value[2];
+ sc.lengths = &h->lengths;
+ sc.values = &h->values;
+ sc.variables = n;
+ sc.complete_lengths = 1;
+ sc.complete_values = 1;
+
+ if (ngx_http_script_compile(&sc) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
return NGX_CONF_OK;
}
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 8e9d0b3f0..6e55c4074 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -2012,6 +2012,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
if (conf->root.data == NULL) {
+ conf->alias = prev->alias;
conf->root = prev->root;
conf->root_lengths = prev->root_lengths;
conf->root_values = prev->root_values;
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 2ec6979d0..91722881e 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -689,6 +689,7 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b)
default:
return NGX_HTTP_PARSE_INVALID_HEADER;
}
+ break;
/* end of header */
case sw_header_almost_done: