diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-02-03 19:33:37 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-02-03 19:33:37 +0000 |
commit | 805d9db723e74bbe84e6df1be29fda28abcc23ea (patch) | |
tree | 7283a5779fba6f4b6048e29cfadeca41428ed773 /src/http/modules/ngx_http_fastcgi_handler.c | |
parent | f3a7b14931aa1e99a31780a93882a5c2e8810c41 (diff) | |
download | nginx-805d9db723e74bbe84e6df1be29fda28abcc23ea.tar.gz nginx-805d9db723e74bbe84e6df1be29fda28abcc23ea.zip |
nginx-0.1.17-RELEASE importrelease-0.1.17
*) Change: the ngx_http_rewrite_module was rewritten from the scratch.
Now it is possible to redirect, to return the error codes, to check
the variables and referrers. The directives can be used inside
locations. The redirect directive was canceled.
*) Feature: the ngx_http_geo_module.
*) Feature: the proxy_set_x_var and fastcgi_set_var directives.
*) Bugfix: the location configuration with "=" modifier may be used in
another location.
*) Bugfix: the correct content type was set only for requests that use
small caps letters in extension.
*) Bugfix: if the proxy_pass or fastcgi_pass directives were set in the
location, and access was denied, and the error was redirected to a
static page, then the segmentation fault occurred.
*) Bugfix: if in a proxied "Location" header was a relative URL, then a
host name and a slash were added to them; the bug had appeared in
0.1.14.
*) Bugfix: the system error message was not logged on Linux.
Diffstat (limited to 'src/http/modules/ngx_http_fastcgi_handler.c')
-rw-r--r-- | src/http/modules/ngx_http_fastcgi_handler.c | 99 |
1 files changed, 98 insertions, 1 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_handler.c b/src/http/modules/ngx_http_fastcgi_handler.c index 9f5016a45..828f7accc 100644 --- a/src/http/modules/ngx_http_fastcgi_handler.c +++ b/src/http/modules/ngx_http_fastcgi_handler.c @@ -20,6 +20,8 @@ typedef struct { ngx_str_t root; ngx_str_t index; + ngx_array_t vars; + ngx_str_t *location; } ngx_http_fastcgi_loc_conf_t; @@ -130,6 +132,8 @@ static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +static char *ngx_http_fastcgi_set_var(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf); static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data); static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf); @@ -306,6 +310,13 @@ static ngx_command_t ngx_http_fastcgi_commands[] = { offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream), &ngx_http_fastcgi_next_upstream_masks }, + { ngx_string("fastcgi_set_var"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_http_fastcgi_set_var, + NGX_HTTP_LOC_CONF_OFFSET, + 0, + NULL }, + { ngx_string("fastcgi_params"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_ANY, ngx_conf_set_bitmask_slot, @@ -405,14 +416,18 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r) ngx_buf_t *b; socklen_t slen; ngx_chain_t *cl, *body; - ngx_uint_t i, n, next; + ngx_uint_t i, n, next, *vindex; ngx_list_part_t *part; ngx_table_elt_t *header; struct sockaddr_in sin; + ngx_http_variable_t *var; + ngx_http_variable_value_t *value; + ngx_http_core_main_conf_t *cmcf; ngx_http_fastcgi_header_t *h; ngx_http_fastcgi_loc_conf_t *flcf; ngx_http_fastcgi_begin_request_t *br; + flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); if ((flcf->params & NGX_HTTP_FASTCGI_SERVER_ADDR) && r->in_addr == 0) { @@ -518,6 +533,23 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r) } + cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); + + var = cmcf->variables.elts; + vindex = flcf->vars.elts; + + for (i = 0; i < flcf->vars.nelts; i++) { + + if (!(value = ngx_http_get_variable(r, vindex[i]))) { + continue; + } + + if (value->text.len) { + len += 1 + 1 + var[vindex[i]].name.len + value->text.len; + } + } + + part = &r->headers_in.headers.part; header = part->elts; @@ -850,6 +882,26 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r) } + for (i = 0; i < flcf->vars.nelts; i++) { + + if (!(value = ngx_http_get_variable(r, vindex[i]))) { + continue; + } + + if (value->text.len == 0) { + continue; + } + + *b->last++ = (u_char) var[vindex[i]].name.len; + *b->last++ = (u_char) value->text.len; + + b->last = ngx_cpymem(b->last, var[vindex[i]].name.data, + var[vindex[i]].name.len); + + b->last = ngx_cpymem(b->last, value->text.data, value->text.len); + } + + part = &r->headers_in.headers.part; header = part->elts; @@ -1763,7 +1815,11 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, clcf->handler = ngx_http_fastcgi_handler; +#if (NGX_PCRE) lcf->location = clcf->regex ? &ngx_http_fastcgi_uri: &clcf->name; +#else + lcf->location = &clcf->name; +#endif if (clcf->name.data[clcf->name.len - 1] == '/') { clcf->auto_redirect = 1; @@ -1773,6 +1829,47 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, } +static char *ngx_http_fastcgi_set_var(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf) +{ + ngx_http_fastcgi_loc_conf_t *lcf = conf; + + ngx_uint_t i, *index; + ngx_str_t *value; + ngx_http_variable_t *var; + ngx_http_core_main_conf_t *cmcf; + + if (lcf->vars.elts == NULL) { + if (ngx_array_init(&lcf->vars, cf->pool, 4, + sizeof(ngx_http_variable_t *)) == NGX_ERROR) + { + return NGX_CONF_ERROR; + } + } + + cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); + + value = cf->args->elts; + + var = cmcf->variables.elts; + for (i = 0; i < cmcf->variables.nelts; i++) { + if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) { + + if (!(index = ngx_array_push(&lcf->vars))) { + return NGX_CONF_ERROR; + } + + *index = var[i].index; + return NGX_CONF_OK; + } + } + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "unknown variable name \"%V\"", &value[1]); + return NGX_CONF_ERROR; +} + + static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data) { |