Ignore:
Timestamp:
02/03/09 19:41:37 (3 years ago)
Author:
George Potapov <nephrite@…>
Branches:
master-v0.7, nginx-v0.7, nginx-v0.8, upstream_count_limit
Children:
2ac4f5
Parents:
2240a4
git-author:
George Potapov <nephrite@…> (02/03/09 19:41:37)
git-committer:
George Potapov <nephrite@…> (02/03/09 19:41:37)
Message:

vendor drop nginx 0.7.31

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/src/http/modules/ngx_http_fastcgi_module.c

    r2240a4 re7b311  
    2323    ngx_array_t                   *fastcgi_lengths; 
    2424    ngx_array_t                   *fastcgi_values; 
     25 
     26#if (NGX_PCRE) 
     27    ngx_regex_t                   *split_regex; 
     28    ngx_str_t                      split_name; 
     29#endif 
    2530} ngx_http_fastcgi_loc_conf_t; 
    2631 
     
    5762 
    5863    ngx_array_t                   *split_parts; 
     64 
     65    ngx_str_t                      script_name; 
     66    ngx_str_t                      path_info; 
    5967} ngx_http_fastcgi_ctx_t; 
    6068 
     
    126134static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, 
    127135    ngx_http_variable_value_t *v, uintptr_t data); 
     136static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, 
     137    ngx_http_variable_value_t *v, uintptr_t data); 
     138static ngx_int_t ngx_http_fastcgi_split(ngx_http_request_t *r, 
     139    ngx_http_fastcgi_ctx_t *f, ngx_http_fastcgi_loc_conf_t *flcf); 
    128140 
    129141static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, 
    130142    void *conf); 
     143static char *ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, 
     144    ngx_command_t *cmd, void *conf); 
    131145static char *ngx_http_fastcgi_store(ngx_conf_t *cf, ngx_command_t *cmd, 
    132146    void *conf); 
     
    170184      NGX_HTTP_LOC_CONF_OFFSET, 
    171185      offsetof(ngx_http_fastcgi_loc_conf_t, index), 
     186      NULL }, 
     187 
     188    { ngx_string("fastcgi_split_path_info"), 
     189      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 
     190      ngx_http_fastcgi_split_path_info, 
     191      NGX_HTTP_LOC_CONF_OFFSET, 
     192      0, 
    172193      NULL }, 
    173194 
     
    391412 
    392413 
    393 static ngx_str_t  ngx_http_fastcgi_script_name = 
    394     ngx_string("fastcgi_script_name"); 
     414static ngx_http_variable_t  ngx_http_fastcgi_vars[] = { 
     415 
     416    { ngx_string("fastcgi_script_name"), NULL, 
     417      ngx_http_fastcgi_script_name_variable, 0, 
     418      NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, 
     419 
     420    { ngx_string("fastcgi_path_info"), NULL, 
     421      ngx_http_fastcgi_path_info_variable, 0, 
     422      NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, 
     423 
     424    { ngx_null_string, NULL, NULL, 0, 0, 0 } 
     425}; 
    395426 
    396427 
     
    411442    ngx_int_t                     rc; 
    412443    ngx_http_upstream_t          *u; 
     444    ngx_http_fastcgi_ctx_t       *f; 
    413445    ngx_http_fastcgi_loc_conf_t  *flcf; 
    414446 
     
    420452    } 
    421453 
    422     ngx_http_set_ctx(r, NULL, ngx_http_fastcgi_module); 
     454    f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); 
     455    if (f == NULL) { 
     456        return NGX_ERROR; 
     457    } 
     458 
     459    ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); 
    423460 
    424461    u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)); 
     
    934971    umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); 
    935972 
    936     if (f == NULL) { 
    937         f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); 
    938         if (f == NULL) { 
    939             return NGX_ERROR; 
    940         } 
    941  
    942         ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); 
    943     } 
    944  
    945973    u = r->upstream; 
    946974 
     
    16671695ngx_http_fastcgi_add_variables(ngx_conf_t *cf) 
    16681696{ 
    1669     ngx_http_variable_t  *var; 
    1670  
    1671     var = ngx_http_add_variable(cf, &ngx_http_fastcgi_script_name, 
    1672                                 NGX_HTTP_VAR_NOHASH|NGX_HTTP_VAR_NOCACHEABLE); 
    1673     if (var == NULL) { 
    1674         return NGX_ERROR; 
    1675     } 
    1676  
    1677     var->get_handler = ngx_http_fastcgi_script_name_variable; 
     1697   ngx_http_variable_t  *var, *v; 
     1698 
     1699    for (v = ngx_http_fastcgi_vars; v->name.len; v++) { 
     1700        var = ngx_http_add_variable(cf, &v->name, v->flags); 
     1701        if (var == NULL) { 
     1702            return NGX_ERROR; 
     1703        } 
     1704 
     1705        var->get_handler = v->get_handler; 
     1706        var->data = v->data; 
     1707    } 
    16781708 
    16791709    return NGX_OK; 
     
    19341964    } 
    19351965 
     1966#if (NGX_PCRE) 
     1967    if (conf->split_regex == NULL) { 
     1968        conf->split_regex = prev->split_regex; 
     1969        conf->split_name = prev->split_name; 
     1970    } 
     1971#endif 
     1972 
    19361973    if (conf->params_source == NULL) { 
    19371974        conf->flushes = prev->flushes; 
     
    20722109{ 
    20732110    u_char                       *p; 
     2111    ngx_http_fastcgi_ctx_t       *f; 
    20742112    ngx_http_fastcgi_loc_conf_t  *flcf; 
    20752113 
    2076     if (r->uri.len) { 
     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); 
     2116 
     2117    if (ngx_http_fastcgi_split(r, f, flcf) != NGX_OK) { 
     2118        return NGX_ERROR; 
     2119    } 
     2120 
     2121    if (f->script_name.len == 0 
     2122        || f->script_name.data[f->script_name.len - 1] != '/') 
     2123    { 
     2124        v->len = f->script_name.len; 
    20772125        v->valid = 1; 
    20782126        v->no_cacheable = 0; 
    20792127        v->not_found = 0; 
    2080  
    2081         flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); 
    2082  
    2083         if (r->uri.data[r->uri.len - 1] != '/') { 
    2084             v->len = r->uri.len; 
    2085             v->data = r->uri.data; 
    2086             return NGX_OK; 
    2087         } 
    2088  
    2089         v->len = r->uri.len + flcf->index.len; 
    2090  
    2091         v->data = ngx_pnalloc(r->pool, v->len); 
    2092         if (v->data == NULL) { 
    2093             return NGX_ERROR; 
    2094         } 
    2095  
    2096         p = ngx_copy(v->data, r->uri.data, r->uri.len); 
    2097         ngx_memcpy(p, flcf->index.data, flcf->index.len); 
    2098  
    2099     } else { 
    2100         v->len = 0; 
    2101         v->valid = 1; 
    2102         v->no_cacheable = 0; 
    2103         v->not_found = 0; 
    2104         v->data = NULL; 
     2128        v->data = f->script_name.data; 
    21052129 
    21062130        return NGX_OK; 
    21072131    } 
    21082132 
     2133    v->len = f->script_name.len + flcf->index.len; 
     2134 
     2135    v->data = ngx_pnalloc(r->pool, v->len); 
     2136    if (v->data == NULL) { 
     2137        return NGX_ERROR; 
     2138    } 
     2139 
     2140    p = ngx_copy(v->data, f->script_name.data, f->script_name.len); 
     2141    ngx_memcpy(p, flcf->index.data, flcf->index.len); 
     2142 
    21092143    return NGX_OK; 
     2144} 
     2145 
     2146 
     2147static ngx_int_t 
     2148ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, 
     2149    ngx_http_variable_value_t *v, uintptr_t data) 
     2150{ 
     2151    ngx_http_fastcgi_ctx_t       *f; 
     2152    ngx_http_fastcgi_loc_conf_t  *flcf; 
     2153 
     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); 
     2156 
     2157    if (ngx_http_fastcgi_split(r, f, flcf) != NGX_OK) { 
     2158        return NGX_ERROR; 
     2159    } 
     2160 
     2161    v->len = f->path_info.len; 
     2162    v->valid = 1; 
     2163    v->no_cacheable = 0; 
     2164    v->not_found = 0; 
     2165    v->data = f->path_info.data; 
     2166 
     2167    return NGX_OK; 
     2168} 
     2169 
     2170 
     2171static ngx_int_t 
     2172ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_ctx_t *f, 
     2173    ngx_http_fastcgi_loc_conf_t *flcf) 
     2174{ 
     2175#if (NGX_PCRE) 
     2176    ngx_int_t  n; 
     2177    int        captures[(1 + 2) * 3]; 
     2178 
     2179    if (f->script_name.len) { 
     2180        return NGX_OK; 
     2181    } 
     2182 
     2183    if (flcf->split_regex == NULL) { 
     2184        f->script_name = r->uri; 
     2185        return NGX_OK; 
     2186    } 
     2187 
     2188    n = ngx_regex_exec(flcf->split_regex, &r->uri, captures, (1 + 2) * 3); 
     2189 
     2190    if (n == NGX_REGEX_NO_MATCHED) { 
     2191        f->script_name = r->uri; 
     2192        return NGX_OK; 
     2193    } 
     2194 
     2195    if (n < 0) { 
     2196        ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 
     2197                      ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"", 
     2198                      n, &r->uri, &flcf->split_name); 
     2199        return NGX_ERROR; 
     2200    } 
     2201 
     2202    /* match */ 
     2203 
     2204    f->script_name.len = captures[3] - captures[2]; 
     2205    f->script_name.data = r->uri.data; 
     2206 
     2207    f->path_info.len = captures[5] - captures[4]; 
     2208    f->path_info.data = r->uri.data + f->script_name.len; 
     2209 
     2210    return NGX_OK; 
     2211 
     2212#else 
     2213 
     2214    f->script_name = r->uri; 
     2215 
     2216    return NGX_OK; 
     2217 
     2218#endif 
    21102219} 
    21112220 
     
    21692278 
    21702279    return NGX_CONF_OK; 
     2280} 
     2281 
     2282 
     2283static char * 
     2284ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 
     2285{ 
     2286#if (NGX_PCRE) 
     2287    ngx_http_fastcgi_loc_conf_t *flcf = conf; 
     2288 
     2289    ngx_int_t   n; 
     2290    ngx_str_t  *value, err; 
     2291    u_char      errstr[NGX_MAX_CONF_ERRSTR]; 
     2292 
     2293    value = cf->args->elts; 
     2294 
     2295    flcf->split_name = value[1]; 
     2296 
     2297    err.len = NGX_MAX_CONF_ERRSTR; 
     2298    err.data = errstr; 
     2299 
     2300    flcf->split_regex = ngx_regex_compile(&value[1], 0, cf->pool, &err); 
     2301 
     2302    if (flcf->split_regex == NULL) { 
     2303        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", err.data); 
     2304        return NGX_CONF_ERROR; 
     2305    } 
     2306 
     2307    n = ngx_regex_capture_count(flcf->split_regex); 
     2308 
     2309    if (n < 0) { 
     2310        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 
     2311                           ngx_regex_capture_count_n " failed for " 
     2312                           "pattern \"%V\"", &value[1]); 
     2313        return NGX_CONF_ERROR; 
     2314    } 
     2315 
     2316    if (n != 2) { 
     2317        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 
     2318                           "pattern \"%V\" must have 2 captures", &value[1]); 
     2319        return NGX_CONF_ERROR; 
     2320    } 
     2321 
     2322    return NGX_CONF_OK; 
     2323 
     2324#else 
     2325 
     2326    ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 
     2327                       "\"%V\" requires PCRE library", &cmd->name); 
     2328    return NGX_CONF_ERROR; 
     2329 
     2330#endif 
    21712331} 
    21722332 
Note: See TracChangeset for help on using the changeset viewer.