]> git.kaiwu.me - nginx.git/commitdiff
Proxy: do not create conf->headers_source when not needed.
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)
src/http/modules/ngx_http_proxy_module.c

index 4f49a527638a7e0aff739864525fddfe6687969d..f7f91d66297db3286a075d7f57589eaf9b8242fb 100644 (file)
@@ -3392,14 +3392,6 @@ ngx_http_proxy_init_headers(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *conf,
         return NGX_ERROR;
     }
 
-    if (conf->headers_source == NULL) {
-        conf->headers_source = ngx_array_create(cf->pool, 4,
-                                                sizeof(ngx_keyval_t));
-        if (conf->headers_source == NULL) {
-            return NGX_ERROR;
-        }
-    }
-
     headers->lengths = ngx_array_create(cf->pool, 64, 1);
     if (headers->lengths == NULL) {
         return NGX_ERROR;
@@ -3410,15 +3402,18 @@ ngx_http_proxy_init_headers(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *conf,
         return NGX_ERROR;
     }
 
-    src = conf->headers_source->elts;
-    for (i = 0; i < conf->headers_source->nelts; i++) {
+    if (conf->headers_source) {
 
-        s = ngx_array_push(&headers_merged);
-        if (s == NULL) {
-            return NGX_ERROR;
-        }
+        src = conf->headers_source->elts;
+        for (i = 0; i < conf->headers_source->nelts; i++) {
+
+            s = ngx_array_push(&headers_merged);
+            if (s == NULL) {
+                return NGX_ERROR;
+            }
 
-        *s = src[i];
+            *s = src[i];
+        }
     }
 
     h = default_headers;