comparison src/http/modules/ngx_http_proxy_module.c @ 7169:e8e19f5e0b8b

Proxy: escape explicit space in URI in default cache key. If the flag space_in_uri is set, the URI in HTTP upstream request is escaped to convert space to %20. However this flag is not checked while creating the default cache key. This leads to different cache keys for requests '/foo bar' and '/foo%20bar', while the upstream requests are identical. Additionally, the change fixes background cache updates when the client URI contains unescaped space. Default cache key in a subrequest is always based on escaped URI, while the main request may not escape it. As a result, background cache update subrequest may update a different cache entry.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 20 Nov 2017 20:50:35 +0300
parents 8530aea9aa50
children 20f139e9ffa8
comparison
equal deleted inserted replaced
7168:46ebff8c6396 7169:e8e19f5e0b8b
1093 return NGX_OK; 1093 return NGX_OK;
1094 } 1094 }
1095 1095
1096 loc_len = (r->valid_location && ctx->vars.uri.len) ? plcf->location.len : 0; 1096 loc_len = (r->valid_location && ctx->vars.uri.len) ? plcf->location.len : 0;
1097 1097
1098 if (r->quoted_uri || r->internal) { 1098 if (r->quoted_uri || r->space_in_uri || r->internal) {
1099 escape = 2 * ngx_escape_uri(NULL, r->uri.data + loc_len, 1099 escape = 2 * ngx_escape_uri(NULL, r->uri.data + loc_len,
1100 r->uri.len - loc_len, NGX_ESCAPE_URI); 1100 r->uri.len - loc_len, NGX_ESCAPE_URI);
1101 } else { 1101 } else {
1102 escape = 0; 1102 escape = 0;
1103 } 1103 }