Fixed missing "Location" field with some relative redirects.

Relative redirects did not work with directory redirects and
auto redirects issued by nginx.
This commit is contained in:
Ruslan Ermilov 2016-12-22 11:58:52 +03:00
parent dd70e74197
commit f021706729
4 changed files with 10 additions and 18 deletions

View File

@ -1067,7 +1067,7 @@ ngx_http_dav_location(ngx_http_request_t *r, u_char *path)
u_char *location; u_char *location;
ngx_http_core_loc_conf_t *clcf; ngx_http_core_loc_conf_t *clcf;
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) { if (r->headers_out.location == NULL) {
return NGX_ERROR; return NGX_ERROR;
} }
@ -1086,11 +1086,8 @@ ngx_http_dav_location(ngx_http_request_t *r, u_char *path)
ngx_memcpy(location, r->uri.data, r->uri.len); ngx_memcpy(location, r->uri.data, r->uri.len);
} }
/* r->headers_out.location->hash = 1;
* we do not need to set the r->headers_out.location->hash and ngx_str_set(&r->headers_out.location->key, "Location");
* r->headers_out.location->key fields
*/
r->headers_out.location->value.len = r->uri.len; r->headers_out.location->value.len = r->uri.len;
r->headers_out.location->value.data = location; r->headers_out.location->value.data = location;

View File

@ -150,7 +150,7 @@ ngx_http_static_handler(ngx_http_request_t *r)
ngx_http_clear_location(r); 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) { if (r->headers_out.location == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }
@ -182,11 +182,8 @@ ngx_http_static_handler(ngx_http_request_t *r)
} }
} }
/* r->headers_out.location->hash = 1;
* we do not need to set the r->headers_out.location->hash and ngx_str_set(&r->headers_out.location->key, "Location");
* r->headers_out.location->key fields
*/
r->headers_out.location->value.len = len; r->headers_out.location->value.len = len;
r->headers_out.location->value.data = location; r->headers_out.location->value.data = location;

View File

@ -983,10 +983,8 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r,
return NGX_OK; return NGX_OK;
} }
/* r->headers_out.location->hash = 1;
* we do not need to set the r->headers_out.location->hash and ngx_str_set(&r->headers_out.location->key, "Location");
* r->headers_out.location->key fields
*/
if (r->args.len == 0) { if (r->args.len == 0) {
r->headers_out.location->value = clcf->name; r->headers_out.location->value = clcf->name;

View File

@ -4927,8 +4927,8 @@ ngx_http_upstream_rewrite_location(ngx_http_request_t *r, ngx_table_elt_t *h,
} }
/* /*
* we do not set r->headers_out.location here to avoid the handling * we do not set r->headers_out.location here to avoid handling
* the local redirects without a host name by ngx_http_header_filter() * relative redirects in ngx_http_header_filter()
*/ */
return NGX_OK; return NGX_OK;