diff src/http/modules/ngx_http_static_module.c @ 6853:c85dfd99a2dd

Fixed missing "Location" field with some relative redirects. Relative redirects did not work with directory redirects and auto redirects issued by nginx.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 22 Dec 2016 11:58:52 +0300
parents b1858fc47e3b
children a72886067bbb
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -150,7 +150,7 @@ ngx_http_static_handler(ngx_http_request
 
         ngx_http_clear_location(r);
 
-        r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));
+        r->headers_out.location = ngx_list_push(&r->headers_out.headers);
         if (r->headers_out.location == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
@@ -182,11 +182,8 @@ ngx_http_static_handler(ngx_http_request
             }
         }
 
-        /*
-         * we do not need to set the r->headers_out.location->hash and
-         * r->headers_out.location->key fields
-         */
-
+        r->headers_out.location->hash = 1;
+        ngx_str_set(&r->headers_out.location->key, "Location");
         r->headers_out.location->value.len = len;
         r->headers_out.location->value.data = location;