comparison src/http/modules/ngx_http_fastcgi_module.c @ 440:6281966854a5 NGINX_0_7_32

nginx 0.7.32 *) Feature: now a directory existence testing can be set explicitly in the "try_files" directive. *) Bugfix: fastcgi_store stored files not always. *) Bugfix: in geo ranges. *) Bugfix: in shared memory allocations if nginx was built without debugging. Thanks to Andrey Kvasov.
author Igor Sysoev <http://sysoev.ru>
date Mon, 26 Jan 2009 00:00:00 +0300
parents ce4f9ff90bfa
children c8cfb6c462ef
comparison
equal deleted inserted replaced
439:02687ee42c28 440:6281966854a5
133 void *parent, void *child); 133 void *parent, void *child);
134 static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, 134 static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r,
135 ngx_http_variable_value_t *v, uintptr_t data); 135 ngx_http_variable_value_t *v, uintptr_t data);
136 static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, 136 static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r,
137 ngx_http_variable_value_t *v, uintptr_t data); 137 ngx_http_variable_value_t *v, uintptr_t data);
138 static ngx_int_t ngx_http_fastcgi_split(ngx_http_request_t *r, 138 static ngx_http_fastcgi_ctx_t *ngx_http_fastcgi_split(ngx_http_request_t *r,
139 ngx_http_fastcgi_ctx_t *f, ngx_http_fastcgi_loc_conf_t *flcf); 139 ngx_http_fastcgi_loc_conf_t *flcf);
140 140
141 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, 141 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
142 void *conf); 142 void *conf);
143 static char *ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, 143 static char *ngx_http_fastcgi_split_path_info(ngx_conf_t *cf,
144 ngx_command_t *cmd, void *conf); 144 ngx_command_t *cmd, void *conf);
2109 { 2109 {
2110 u_char *p; 2110 u_char *p;
2111 ngx_http_fastcgi_ctx_t *f; 2111 ngx_http_fastcgi_ctx_t *f;
2112 ngx_http_fastcgi_loc_conf_t *flcf; 2112 ngx_http_fastcgi_loc_conf_t *flcf;
2113 2113
2114 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
2115 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); 2114 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
2116 2115
2117 if (ngx_http_fastcgi_split(r, f, flcf) != NGX_OK) { 2116 f = ngx_http_fastcgi_split(r, flcf);
2117
2118 if (f == NULL) {
2118 return NGX_ERROR; 2119 return NGX_ERROR;
2119 } 2120 }
2120 2121
2121 if (f->script_name.len == 0 2122 if (f->script_name.len == 0
2122 || f->script_name.data[f->script_name.len - 1] != '/') 2123 || f->script_name.data[f->script_name.len - 1] != '/')
2149 ngx_http_variable_value_t *v, uintptr_t data) 2150 ngx_http_variable_value_t *v, uintptr_t data)
2150 { 2151 {
2151 ngx_http_fastcgi_ctx_t *f; 2152 ngx_http_fastcgi_ctx_t *f;
2152 ngx_http_fastcgi_loc_conf_t *flcf; 2153 ngx_http_fastcgi_loc_conf_t *flcf;
2153 2154
2154 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
2155 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); 2155 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
2156 2156
2157 if (ngx_http_fastcgi_split(r, f, flcf) != NGX_OK) { 2157 f = ngx_http_fastcgi_split(r, flcf);
2158
2159 if (f == NULL) {
2158 return NGX_ERROR; 2160 return NGX_ERROR;
2159 } 2161 }
2160 2162
2161 v->len = f->path_info.len; 2163 v->len = f->path_info.len;
2162 v->valid = 1; 2164 v->valid = 1;
2166 2168
2167 return NGX_OK; 2169 return NGX_OK;
2168 } 2170 }
2169 2171
2170 2172
2171 static ngx_int_t 2173 static ngx_http_fastcgi_ctx_t *
2172 ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_ctx_t *f, 2174 ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf)
2173 ngx_http_fastcgi_loc_conf_t *flcf)
2174 { 2175 {
2176 ngx_http_fastcgi_ctx_t *f;
2175 #if (NGX_PCRE) 2177 #if (NGX_PCRE)
2176 ngx_int_t n; 2178 ngx_int_t n;
2177 int captures[(1 + 2) * 3]; 2179 int captures[(1 + 2) * 3];
2180
2181 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
2182
2183 if (f == NULL) {
2184 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t));
2185 if (f == NULL) {
2186 return NULL;
2187 }
2188
2189 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module);
2190 }
2178 2191
2179 if (f->script_name.len) { 2192 if (f->script_name.len) {
2180 return NGX_OK; 2193 return f;
2181 } 2194 }
2182 2195
2183 if (flcf->split_regex == NULL) { 2196 if (flcf->split_regex == NULL) {
2184 f->script_name = r->uri; 2197 f->script_name = r->uri;
2185 return NGX_OK; 2198 return f;
2186 } 2199 }
2187 2200
2188 n = ngx_regex_exec(flcf->split_regex, &r->uri, captures, (1 + 2) * 3); 2201 n = ngx_regex_exec(flcf->split_regex, &r->uri, captures, (1 + 2) * 3);
2189 2202
2190 if (n == NGX_REGEX_NO_MATCHED) { 2203 if (n == NGX_REGEX_NO_MATCHED) {
2191 f->script_name = r->uri; 2204 f->script_name = r->uri;
2192 return NGX_OK; 2205 return f;
2193 } 2206 }
2194 2207
2195 if (n < 0) { 2208 if (n < 0) {
2196 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 2209 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
2197 ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"", 2210 ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"",
2198 n, &r->uri, &flcf->split_name); 2211 n, &r->uri, &flcf->split_name);
2199 return NGX_ERROR; 2212 return NULL;
2200 } 2213 }
2201 2214
2202 /* match */ 2215 /* match */
2203 2216
2204 f->script_name.len = captures[3] - captures[2]; 2217 f->script_name.len = captures[3] - captures[2];
2205 f->script_name.data = r->uri.data; 2218 f->script_name.data = r->uri.data;
2206 2219
2207 f->path_info.len = captures[5] - captures[4]; 2220 f->path_info.len = captures[5] - captures[4];
2208 f->path_info.data = r->uri.data + f->script_name.len; 2221 f->path_info.data = r->uri.data + f->script_name.len;
2209 2222
2210 return NGX_OK; 2223 return f;
2211 2224
2212 #else 2225 #else
2213 2226
2227 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
2228
2229 if (f == NULL) {
2230 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t));
2231 if (f == NULL) {
2232 return NULL;
2233 }
2234
2235 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module);
2236 }
2237
2214 f->script_name = r->uri; 2238 f->script_name = r->uri;
2215 2239
2216 return NGX_OK; 2240 return f;
2217 2241
2218 #endif 2242 #endif
2219 } 2243 }
2220 2244
2221 2245