]> git.kaiwu.me - nginx.git/commitdiff
Upstream: hide_headers_hash handling at http level.
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 14 Oct 2016 16:48:26 +0000 (19:48 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Fri, 14 Oct 2016 16:48:26 +0000 (19:48 +0300)
When headers to hide are set at the "http" level and not redefined in
a server block, we now preserve compiled headers hash into the "http"
section configuration to inherit this hash to all servers.

src/http/ngx_http_upstream.c

index c2afa0cd5fb6fcdb6050958ea3d321c4ebce5e0e..4d5bea35eb2839ff29a4c9ade5b56ceec1a7c25c 100644 (file)
@@ -6106,7 +6106,23 @@ ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
     hash->pool = cf->pool;
     hash->temp_pool = NULL;
 
-    return ngx_hash_init(hash, hide_headers.elts, hide_headers.nelts);
+    if (ngx_hash_init(hash, hide_headers.elts, hide_headers.nelts) != NGX_OK) {
+        return NGX_ERROR;
+    }
+
+    /*
+     * special handling to preserve conf->hide_headers_hash
+     * in the "http" section to inherit it to all servers
+     */
+
+    if (prev->hide_headers_hash.buckets == NULL
+        && conf->hide_headers == prev->hide_headers
+        && conf->pass_headers == prev->pass_headers)
+    {
+        prev->hide_headers_hash = conf->hide_headers_hash;
+    }
+
+    return NGX_OK;
 }