comparison src/http/ngx_http_core_module.c @ 464:c8cfb6c462ef NGINX_0_7_44

nginx 0.7.44 *) Feature: the ngx_http_proxy_module preliminary cache support. *) Feature: the --with-pcre option in the configure. *) Feature: the "try_files" directive is now allowed on the server block level. *) Bugfix: the "try_files" directive handled incorrectly a query string in a fallback parameter. *) Bugfix: the "try_files" directive might test incorrectly directories. *) Bugfix: if there is the single server for given address:port pair, then captures in regular expressions in a "server_name" directive did not work.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Mar 2009 00:00:00 +0300
parents dcb6b5f9d526
children 56baf312c1b5
comparison
equal deleted inserted replaced
463:51cb914e6d3a 464:c8cfb6c462ef
117 { ngx_string("before"), NGX_HTTP_IMS_BEFORE }, 117 { ngx_string("before"), NGX_HTTP_IMS_BEFORE },
118 { ngx_null_string, 0 } 118 { ngx_null_string, 0 }
119 }; 119 };
120 120
121 121
122 static ngx_path_init_t ngx_http_client_temp_path = {
123 ngx_string(NGX_HTTP_CLIENT_TEMP_PATH), { 0, 0, 0 }
124 };
125
126
122 #if (NGX_HTTP_GZIP) 127 #if (NGX_HTTP_GZIP)
123 128
124 static ngx_conf_enum_t ngx_http_gzip_http_version[] = { 129 static ngx_conf_enum_t ngx_http_gzip_http_version[] = {
125 { ngx_string("1.0"), NGX_HTTP_VERSION_10 }, 130 { ngx_string("1.0"), NGX_HTTP_VERSION_10 },
126 { ngx_string("1.1"), NGX_HTTP_VERSION_11 }, 131 { ngx_string("1.1"), NGX_HTTP_VERSION_11 },
345 { ngx_string("client_body_temp_path"), 350 { ngx_string("client_body_temp_path"),
346 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, 351 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
347 ngx_conf_set_path_slot, 352 ngx_conf_set_path_slot,
348 NGX_HTTP_LOC_CONF_OFFSET, 353 NGX_HTTP_LOC_CONF_OFFSET,
349 offsetof(ngx_http_core_loc_conf_t, client_body_temp_path), 354 offsetof(ngx_http_core_loc_conf_t, client_body_temp_path),
350 (void *) ngx_garbage_collector_temp_handler }, 355 NULL },
351 356
352 { ngx_string("client_body_in_file_only"), 357 { ngx_string("client_body_in_file_only"),
353 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 358 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
354 ngx_conf_set_enum_slot, 359 ngx_conf_set_enum_slot,
355 NGX_HTTP_LOC_CONF_OFFSET, 360 NGX_HTTP_LOC_CONF_OFFSET,
540 NGX_HTTP_LOC_CONF_OFFSET, 545 NGX_HTTP_LOC_CONF_OFFSET,
541 0, 546 0,
542 NULL }, 547 NULL },
543 548
544 { ngx_string("try_files"), 549 { ngx_string("try_files"),
545 NGX_HTTP_LOC_CONF|NGX_CONF_2MORE, 550 NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
546 ngx_http_core_try_files, 551 ngx_http_core_try_files,
547 NGX_HTTP_LOC_CONF_OFFSET, 552 NGX_HTTP_LOC_CONF_OFFSET,
548 0, 553 0,
549 NULL }, 554 NULL },
550 555
1035 ngx_http_core_try_files_phase(ngx_http_request_t *r, 1040 ngx_http_core_try_files_phase(ngx_http_request_t *r,
1036 ngx_http_phase_handler_t *ph) 1041 ngx_http_phase_handler_t *ph)
1037 { 1042 {
1038 size_t len, root, alias, reserve, allocated; 1043 size_t len, root, alias, reserve, allocated;
1039 u_char *p, *name; 1044 u_char *p, *name;
1040 ngx_str_t path; 1045 ngx_str_t path, args;
1041 ngx_uint_t test_dir; 1046 ngx_uint_t test_dir;
1042 ngx_http_try_file_t *tf; 1047 ngx_http_try_file_t *tf;
1043 ngx_open_file_info_t of; 1048 ngx_open_file_info_t of;
1044 ngx_http_script_code_pt code; 1049 ngx_http_script_code_pt code;
1045 ngx_http_script_engine_t e; 1050 ngx_http_script_engine_t e;
1132 1137
1133 test_dir = tf->test_dir; 1138 test_dir = tf->test_dir;
1134 1139
1135 tf++; 1140 tf++;
1136 1141
1137 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1142 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1138 "try to use file: \"%s\"", name); 1143 "try to use file: \"%s\" \"%s\"", name, path.data);
1139 1144
1140 if (tf->lengths == NULL && tf->name.len == 0) { 1145 if (tf->lengths == NULL && tf->name.len == 0) {
1141 1146
1142 path.len -= root; 1147 path.len -= root;
1143 path.data += root; 1148 path.data += root;
1144 1149
1145 if (path.data[0] == '@') { 1150 if (path.data[0] == '@') {
1146 (void) ngx_http_named_location(r, &path); 1151 (void) ngx_http_named_location(r, &path);
1147 1152
1148 } else { 1153 } else {
1149 (void) ngx_http_internal_redirect(r, &path, NULL); 1154 ngx_http_split_args(r, &path, &args);
1155
1156 (void) ngx_http_internal_redirect(r, &path, &args);
1150 } 1157 }
1151 1158
1152 return NGX_OK; 1159 return NGX_OK;
1153 } 1160 }
1154 1161
2180 2187
2181 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 2188 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
2182 r->loc_conf = cscf->ctx->loc_conf; 2189 r->loc_conf = cscf->ctx->loc_conf;
2183 2190
2184 ngx_http_update_location_config(r); 2191 ngx_http_update_location_config(r);
2192
2193 #if (NGX_HTTP_CACHE)
2194 r->cache = NULL;
2195 #endif
2185 2196
2186 r->internal = 1; 2197 r->internal = 1;
2187 2198
2188 ngx_http_handler(r); 2199 ngx_http_handler(r);
2189 2200
3152 } 3163 }
3153 3164
3154 conf->resolver = prev->resolver; 3165 conf->resolver = prev->resolver;
3155 } 3166 }
3156 3167
3157 ngx_conf_merge_path_value(conf->client_body_temp_path, 3168 if (ngx_conf_merge_path_value(cf, &conf->client_body_temp_path,
3158 prev->client_body_temp_path, 3169 prev->client_body_temp_path,
3159 NGX_HTTP_CLIENT_TEMP_PATH, 0, 0, 0, 3170 &ngx_http_client_temp_path)
3160 ngx_garbage_collector_temp_handler, cf); 3171 != NGX_OK)
3172 {
3173 return NGX_CONF_ERROR;
3174 }
3161 3175
3162 ngx_conf_merge_value(conf->reset_timedout_connection, 3176 ngx_conf_merge_value(conf->reset_timedout_connection,
3163 prev->reset_timedout_connection, 0); 3177 prev->reset_timedout_connection, 0);
3164 ngx_conf_merge_value(conf->server_name_in_redirect, 3178 ngx_conf_merge_value(conf->server_name_in_redirect,
3165 prev->server_name_in_redirect, 1); 3179 prev->server_name_in_redirect, 1);
3787 static char * 3801 static char *
3788 ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 3802 ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
3789 { 3803 {
3790 ngx_http_core_loc_conf_t *lcf = conf; 3804 ngx_http_core_loc_conf_t *lcf = conf;
3791 3805
3792 u_char *args; 3806 u_char *p;
3793 ngx_int_t overwrite; 3807 ngx_int_t overwrite;
3794 ngx_str_t *value, uri; 3808 ngx_str_t *value, uri, args;
3795 ngx_uint_t i, n, nvar; 3809 ngx_uint_t i, n;
3796 ngx_array_t *uri_lengths, *uri_values; 3810 ngx_http_err_page_t *err;
3797 ngx_http_err_page_t *err; 3811 ngx_http_complex_value_t cv;
3798 ngx_http_script_compile_t sc; 3812 ngx_http_compile_complex_value_t ccv;
3799 3813
3800 if (lcf->error_pages == NULL) { 3814 if (lcf->error_pages == NULL) {
3801 lcf->error_pages = ngx_array_create(cf->pool, 4, 3815 lcf->error_pages = ngx_array_create(cf->pool, 4,
3802 sizeof(ngx_http_err_page_t)); 3816 sizeof(ngx_http_err_page_t));
3803 if (lcf->error_pages == NULL) { 3817 if (lcf->error_pages == NULL) {
3835 overwrite = -1; 3849 overwrite = -1;
3836 n = 1; 3850 n = 1;
3837 } 3851 }
3838 3852
3839 uri = value[cf->args->nelts - 1]; 3853 uri = value[cf->args->nelts - 1];
3840 uri_lengths = NULL; 3854
3841 uri_values = NULL; 3855 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
3842 3856
3843 nvar = ngx_http_script_variables_count(&uri); 3857 ccv.cf = cf;
3844 3858 ccv.value = &uri;
3845 if (nvar) { 3859 ccv.complex_value = &cv;
3846 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); 3860
3847 3861 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
3848 sc.cf = cf; 3862 return NGX_CONF_ERROR;
3849 sc.source = &uri; 3863 }
3850 sc.lengths = &uri_lengths; 3864
3851 sc.values = &uri_values; 3865 args.len = 0;
3852 sc.variables = nvar; 3866 args.data = NULL;
3853 sc.complete_lengths = 1; 3867
3854 sc.complete_values = 1; 3868 if (cv.lengths == NULL) {
3855 3869 p = (u_char *) ngx_strchr(uri.data, '?');
3856 if (ngx_http_script_compile(&sc) != NGX_OK) { 3870
3857 return NGX_CONF_ERROR; 3871 if (p) {
3858 } 3872 cv.value.len = p - uri.data;
3859 } 3873 cv.value.data = uri.data;
3860 3874 p++;
3861 args = (u_char *) ngx_strchr(uri.data, '?'); 3875 args.len = (uri.data + uri.len) - p;
3876 args.data = p;
3877 }
3878 }
3862 3879
3863 for (i = 1; i < cf->args->nelts - n; i++) { 3880 for (i = 1; i < cf->args->nelts - n; i++) {
3864 err = ngx_array_push(lcf->error_pages); 3881 err = ngx_array_push(lcf->error_pages);
3865 if (err == NULL) { 3882 if (err == NULL) {
3866 return NGX_CONF_ERROR; 3883 return NGX_CONF_ERROR;
3896 err->overwrite = err->status; 3913 err->overwrite = err->status;
3897 break; 3914 break;
3898 } 3915 }
3899 } 3916 }
3900 3917
3901 if (args) { 3918 err->value = cv;
3902 err->uri.len = args - uri.data; 3919 err->args = args;
3903 err->uri.data = uri.data;
3904 args++;
3905 err->args.len = (uri.data + uri.len) - args;
3906 err->args.data = args;
3907
3908 } else {
3909 err->uri = uri;
3910 err->args.len = 0;
3911 err->args.data = NULL;
3912 }
3913
3914 err->uri_lengths = uri_lengths;
3915 err->uri_values = uri_values;
3916 } 3920 }
3917 3921
3918 return NGX_CONF_OK; 3922 return NGX_CONF_OK;
3919 } 3923 }
3920 3924
3952 tf[i].name = value[i + 1]; 3956 tf[i].name = value[i + 1];
3953 3957
3954 if (tf[i].name.data[tf[i].name.len - 1] == '/') { 3958 if (tf[i].name.data[tf[i].name.len - 1] == '/') {
3955 tf[i].test_dir = 1; 3959 tf[i].test_dir = 1;
3956 tf[i].name.len--; 3960 tf[i].name.len--;
3961 tf[i].name.data[tf[i].name.len] = '\0';
3957 } 3962 }
3958 3963
3959 n = ngx_http_script_variables_count(&tf[i].name); 3964 n = ngx_http_script_variables_count(&tf[i].name);
3960 3965
3961 if (n) { 3966 if (n) {