Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_core_module.c @ 574:7858d4f8dec4 NGINX_0_8_39
nginx 0.8.39
*) Bugfix: an inherited "alias" directive worked incorrectly in
inclusive location.
*) Bugfix: in "alias" with variables and "try_files" directives
combination.
*) Bugfix: listen unix domain and IPv6 sockets did not inherit while
online upgrade.
Thanks to Maxim Dounin.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 31 May 2010 00:00:00 +0400 |
parents | ff463db0be31 |
children | bc110f60c0de |
comparison
equal
deleted
inserted
replaced
573:7cbc7affef15 | 574:7858d4f8dec4 |
---|---|
1150 /* suppress MSVC warning */ | 1150 /* suppress MSVC warning */ |
1151 path.data = NULL; | 1151 path.data = NULL; |
1152 | 1152 |
1153 tf = clcf->try_files; | 1153 tf = clcf->try_files; |
1154 | 1154 |
1155 alias = clcf->alias ? clcf->name.len : 0; | 1155 alias = clcf->alias; |
1156 | 1156 |
1157 for ( ;; ) { | 1157 for ( ;; ) { |
1158 | 1158 |
1159 if (tf->lengths) { | 1159 if (tf->lengths) { |
1160 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | 1160 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); |
1220 | 1220 |
1221 test_dir = tf->test_dir; | 1221 test_dir = tf->test_dir; |
1222 | 1222 |
1223 tf++; | 1223 tf++; |
1224 | 1224 |
1225 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1225 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1226 "try to use file: \"%s\" \"%s\"", name, path.data); | 1226 "try to use %s: \"%s\" \"%s\"", |
1227 test_dir ? "dir" : "file", name, path.data); | |
1227 | 1228 |
1228 if (tf->lengths == NULL && tf->name.len == 0) { | 1229 if (tf->lengths == NULL && tf->name.len == 0) { |
1229 | 1230 |
1230 if (tf->code) { | 1231 if (tf->code) { |
1231 ngx_http_finalize_request(r, tf->code); | 1232 ngx_http_finalize_request(r, tf->code); |
1279 path.data += root; | 1280 path.data += root; |
1280 | 1281 |
1281 if (!alias) { | 1282 if (!alias) { |
1282 r->uri = path; | 1283 r->uri = path; |
1283 | 1284 |
1285 #if (NGX_PCRE) | |
1286 } else if (clcf->regex) { | |
1287 if (!test_dir) { | |
1288 r->uri = path; | |
1289 r->add_uri_to_alias = 1; | |
1290 } | |
1291 #endif | |
1284 } else { | 1292 } else { |
1285 r->uri.len = alias + path.len; | 1293 r->uri.len = alias + path.len; |
1286 r->uri.data = ngx_pnalloc(r->pool, r->uri.len); | 1294 r->uri.data = ngx_pnalloc(r->pool, r->uri.len); |
1287 if (r->uri.data == NULL) { | 1295 if (r->uri.data == NULL) { |
1288 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 1296 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1746 size_t alias; | 1754 size_t alias; |
1747 ngx_http_core_loc_conf_t *clcf; | 1755 ngx_http_core_loc_conf_t *clcf; |
1748 | 1756 |
1749 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 1757 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1750 | 1758 |
1751 alias = clcf->alias ? clcf->name.len : 0; | 1759 alias = clcf->alias; |
1752 | 1760 |
1753 if (alias && !r->valid_location) { | 1761 if (alias && !r->valid_location) { |
1754 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | 1762 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
1755 "\"alias\" could not be used in location \"%V\" " | 1763 "\"alias\" could not be used in location \"%V\" " |
1756 "where URI was rewritten", &clcf->name); | 1764 "where URI was rewritten", &clcf->name); |
1774 | 1782 |
1775 #if (NGX_PCRE) | 1783 #if (NGX_PCRE) |
1776 ngx_uint_t captures; | 1784 ngx_uint_t captures; |
1777 | 1785 |
1778 captures = alias && clcf->regex; | 1786 captures = alias && clcf->regex; |
1779 reserved += captures ? 1 : r->uri.len - alias + 1; | 1787 |
1788 reserved += captures ? r->add_uri_to_alias ? r->uri.len + 1 : 1 | |
1789 : r->uri.len - alias + 1; | |
1780 #else | 1790 #else |
1781 reserved += r->uri.len - alias + 1; | 1791 reserved += r->uri.len - alias + 1; |
1782 #endif | 1792 #endif |
1783 | 1793 |
1784 if (ngx_http_script_run(r, path, clcf->root_lengths->elts, reserved, | 1794 if (ngx_http_script_run(r, path, clcf->root_lengths->elts, reserved, |
1795 *root_length = path->len - reserved; | 1805 *root_length = path->len - reserved; |
1796 last = path->data + *root_length; | 1806 last = path->data + *root_length; |
1797 | 1807 |
1798 #if (NGX_PCRE) | 1808 #if (NGX_PCRE) |
1799 if (captures) { | 1809 if (captures) { |
1800 *last = '\0'; | 1810 if (!r->add_uri_to_alias) { |
1801 return last; | 1811 *last = '\0'; |
1812 return last; | |
1813 } | |
1814 | |
1815 alias = 0; | |
1802 } | 1816 } |
1803 #endif | 1817 #endif |
1804 } | 1818 } |
1805 | 1819 |
1806 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1); | 1820 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1); |
2204 #if (NGX_HTTP_CACHE) | 2218 #if (NGX_HTTP_CACHE) |
2205 r->cache = NULL; | 2219 r->cache = NULL; |
2206 #endif | 2220 #endif |
2207 | 2221 |
2208 r->internal = 1; | 2222 r->internal = 1; |
2223 r->add_uri_to_alias = 0; | |
2209 r->main->count++; | 2224 r->main->count++; |
2210 | 2225 |
2211 ngx_http_handler(r); | 2226 ngx_http_handler(r); |
2212 | 2227 |
2213 return NGX_DONE; | 2228 return NGX_DONE; |
3587 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 3602 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
3588 { | 3603 { |
3589 ngx_http_core_loc_conf_t *clcf = conf; | 3604 ngx_http_core_loc_conf_t *clcf = conf; |
3590 | 3605 |
3591 ngx_str_t *value; | 3606 ngx_str_t *value; |
3592 ngx_uint_t alias, n; | 3607 ngx_int_t alias; |
3608 ngx_uint_t n; | |
3593 ngx_http_script_compile_t sc; | 3609 ngx_http_script_compile_t sc; |
3594 | 3610 |
3595 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; | 3611 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; |
3596 | 3612 |
3597 if (clcf->root.data) { | 3613 if (clcf->root.data) { |
3598 | 3614 |
3599 /* the (ngx_uint_t) cast is required by gcc 2.7.2.3 */ | 3615 if ((clcf->alias != 0) == alias) { |
3600 | |
3601 if ((ngx_uint_t) clcf->alias == alias) { | |
3602 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3616 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3603 "\"%V\" directive is duplicate", | 3617 "\"%V\" directive is duplicate", |
3604 &cmd->name); | 3618 &cmd->name); |
3605 } else { | 3619 } else { |
3606 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3620 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3642 &cmd->name); | 3656 &cmd->name); |
3643 | 3657 |
3644 return NGX_CONF_ERROR; | 3658 return NGX_CONF_ERROR; |
3645 } | 3659 } |
3646 | 3660 |
3647 clcf->alias = alias; | 3661 clcf->alias = alias ? clcf->name.len : 0; |
3648 clcf->root = value[1]; | 3662 clcf->root = value[1]; |
3649 | 3663 |
3650 if (!alias && clcf->root.data[clcf->root.len - 1] == '/') { | 3664 if (!alias && clcf->root.data[clcf->root.len - 1] == '/') { |
3651 clcf->root.len--; | 3665 clcf->root.len--; |
3652 } | 3666 } |