Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

back-ported a bugfix from ngx_lua: in output header set, we should al…

…ways set the header->hash to 1. thanks moodydeath for reporting it.
  • Loading branch information...
commit b1c4273ae5a3914f8ddc762f19aafe2c14447677 1 parent 6a12aa5
@agentzh agentzh authored
Showing with 49 additions and 6 deletions.
  1. +13 −5 src/ngx_http_headers_more_headers_out.c
  2. +34 −1 t/bug.t
  3. +2 −0  util/build.sh
View
18 src/ngx_http_headers_more_headers_out.c
@@ -166,7 +166,6 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_headers_more_header_v
ngx_uint_t i;
ngx_flag_t matched = 0;
-
dd_enter();
part = &r->headers_out.headers.part;
@@ -198,19 +197,23 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_headers_more_header_v
dd("clearing normal header for %.*s", (int) hv->key.len,
hv->key.data);
+ h[i].value.len = 0;
h[i].hash = 0;
- }
- h[i].value = *value;
+ } else {
+ h[i].value = *value;
+ h[i].hash = 1;
+ }
if (output_header) {
*output_header = &h[i];
}
+
if (!hv->wildcard){
return NGX_OK;
- } else {
- matched = 1;
}
+
+ matched = 1;
}
}
@@ -222,6 +225,10 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_headers_more_header_v
return NGX_OK;
}
+ /* XXX we still need to create header slot even if the value
+ * is empty because some builtin headers like Last-Modified
+ * relies on this to get cleared */
+
h = ngx_list_push(&r->headers_out.headers);
if (h == NULL) {
@@ -230,6 +237,7 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_headers_more_header_v
if (value->len == 0) {
h->hash = 0;
+
} else {
h->hash = hv->hash;
}
View
35 t/bug.t
@@ -4,7 +4,7 @@ use Test::Nginx::Socket; # 'no_plan';
#repeat_each(2);
-plan tests => 20 * repeat_each();
+plan tests => 26 * repeat_each();
no_diff;
@@ -145,3 +145,36 @@ html>
! Accept-Ranges
--- response_body_like: It works
+
+
+=== TEST 9: clear first, then add
+--- config
+ location /bug {
+ more_clear_headers 'Foo';
+ more_set_headers 'Foo: a';
+ echo hello;
+ }
+--- request
+ GET /bug
+--- raw_response_headers_like eval
+".*Foo: a.*"
+--- response_body
+hello
+
+
+
+=== TEST 10: first add, then clear, then add again
+--- config
+ location /bug {
+ more_set_headers 'Foo: a';
+ more_clear_headers 'Foo';
+ more_set_headers 'Foo: b';
+ echo hello;
+ }
+--- request
+ GET /bug
+--- raw_response_headers_like eval
+".*Foo: b.*"
+--- response_body
+hello
+
View
2  util/build.sh
@@ -32,6 +32,8 @@ cd nginx-$version/ || exit 1
if [[ "$BUILD_CLEAN" -eq 1 || ! -f Makefile || "$root/config" -nt Makefile || "$root/util/build.sh" -nt Makefile ]]; then
./configure --prefix=$target \
+ --with-cc-opt="-O0 -fprofile-arcs -ftest-coverage" \
+ --with-ld-opt="-fprofile-arcs -ftest-coverage" \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
Please sign in to comment.
Something went wrong with that request. Please try again.