comparison 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
comparison
equal deleted inserted replaced
6852:d15172ebb400 6853:c85dfd99a2dd
148 148
149 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir"); 149 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir");
150 150
151 ngx_http_clear_location(r); 151 ngx_http_clear_location(r);
152 152
153 r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t)); 153 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
154 if (r->headers_out.location == NULL) { 154 if (r->headers_out.location == NULL) {
155 return NGX_HTTP_INTERNAL_SERVER_ERROR; 155 return NGX_HTTP_INTERNAL_SERVER_ERROR;
156 } 156 }
157 157
158 len = r->uri.len + 1; 158 len = r->uri.len + 1;
180 *++last = '?'; 180 *++last = '?';
181 ngx_memcpy(++last, r->args.data, r->args.len); 181 ngx_memcpy(++last, r->args.data, r->args.len);
182 } 182 }
183 } 183 }
184 184
185 /* 185 r->headers_out.location->hash = 1;
186 * we do not need to set the r->headers_out.location->hash and 186 ngx_str_set(&r->headers_out.location->key, "Location");
187 * r->headers_out.location->key fields
188 */
189
190 r->headers_out.location->value.len = len; 187 r->headers_out.location->value.len = len;
191 r->headers_out.location->value.data = location; 188 r->headers_out.location->value.data = location;
192 189
193 return NGX_HTTP_MOVED_PERMANENTLY; 190 return NGX_HTTP_MOVED_PERMANENTLY;
194 } 191 }