Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-01-19 16:10:56 +0300
committerIgor Sysoev <igor@sysoev.ru>2005-01-19 16:10:56 +0300
commit3259e85b7a1ce51d2e65360173c373fcca3609fb (patch)
tree6165dfb25d57d8b2d7cc914069a4c150b168354b /src/http
parentfbf4fc0da9018ef2d11470b6ac295385ecf53091 (diff)
nginx-0.1.15-RELEASE importrelease-0.1.15
*) Bugfix: the error while the connecting to the FastCGI server caused segmentation fault. *) Bugfix: the correct handling of the regular expression, that has different number of the captures and substitutions. *) Feature: the location, that is passed to the FastCGI server, can be regular expression. *) Bugfix: the FastCGI's parameter REQUEST_URI is now passed with the arguments and in the original state. *) Bugfix: the ngx_http_rewrite_module module was required to be built to use the regular expressions in locations. *) Bugfix: the directive "proxy_preserve_host on" adds port 80 to the "Host" headers, if upstream listen on port 80; the bug had appeared in 0.1.14. *) Bugfix: the same paths in autoconfiguration parameters --http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH, or --http-client-body-temp-path=PATH and --http-fastcgi-temp-path=PATH caused segmentation fault.
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_fastcgi_handler.c15
-rw-r--r--src/http/modules/ngx_http_rewrite_handler.c51
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c1
-rw-r--r--src/http/ngx_http_core_module.c2
-rw-r--r--src/http/ngx_http_upstream.c4
5 files changed, 47 insertions, 26 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_handler.c b/src/http/modules/ngx_http_fastcgi_handler.c
index f38646a9b..41efa0bb9 100644
--- a/src/http/modules/ngx_http_fastcgi_handler.c
+++ b/src/http/modules/ngx_http_fastcgi_handler.c
@@ -144,6 +144,9 @@ static ngx_str_t ngx_http_fastcgi_methods[] = {
};
+static ngx_str_t ngx_http_fastcgi_uri = ngx_string("/");
+
+
static ngx_http_header_t ngx_http_fastcgi_headers_in[] = {
{ ngx_string("Status"), offsetof(ngx_http_fastcgi_headers_in_t, status) },
@@ -474,8 +477,8 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
}
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
- len += 1 + ((r->uri.len > 127) ? 4 : 1)
- + sizeof("REQUEST_URI") - 1 + r->uri.len;
+ len += 1 + ((r->unparsed_uri.len > 127) ? 4 : 1)
+ + sizeof("REQUEST_URI") - 1 + r->unparsed_uri.len;
}
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
@@ -734,7 +737,7 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
*b->last++ = sizeof("REQUEST_URI") - 1;
- len = r->uri.len;
+ len = r->unparsed_uri.len;
if (len > 127) {
*b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80);
*b->last++ = (u_char) ((len >> 16) & 0xff);
@@ -746,7 +749,7 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
}
b->last = ngx_cpymem(b->last, "REQUEST_URI", sizeof("REQUEST_URI") - 1);
- b->last = ngx_cpymem(b->last, r->uri.data, len);
+ b->last = ngx_cpymem(b->last, r->unparsed_uri.data, len);
}
@@ -1718,7 +1721,6 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
unix_upstream.name = value[1];
unix_upstream.url = value[1];
-
if (!(lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream))) {
return NGX_CONF_ERROR;
}
@@ -1744,9 +1746,10 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
- lcf->location = &clcf->name;
clcf->handler = ngx_http_fastcgi_handler;
+ lcf->location = clcf->regex ? &ngx_http_fastcgi_uri: &clcf->name;
+
if (clcf->name.data[clcf->name.len - 1] == '/') {
clcf->auto_redirect = 1;
}
diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c
index 0973ef087..002edb88d 100644
--- a/src/http/modules/ngx_http_rewrite_handler.c
+++ b/src/http/modules/ngx_http_rewrite_handler.c
@@ -23,7 +23,7 @@ typedef struct {
typedef struct {
ngx_regex_t *regex;
- ngx_uint_t msize;
+ ngx_uint_t ncaptures;
ngx_array_t ops;
ngx_uint_t size;
@@ -113,7 +113,7 @@ ngx_module_t ngx_http_rewrite_module = {
static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
{
- int *matches;
+ int *captures;
u_char *p;
size_t len;
uintptr_t data;
@@ -132,18 +132,20 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
rule = scf->rules.elts;
for (i = 0; i < scf->rules.nelts; i++) {
- if (rule[i].msize) {
- if (!(matches = ngx_palloc(r->pool, rule[i].msize * sizeof(int)))) {
+ if (rule[i].ncaptures) {
+ captures = ngx_palloc(r->pool, rule[i].ncaptures * sizeof(int));
+ if (captures == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
} else {
- matches = NULL;
+ captures = NULL;
}
- rc = ngx_regex_exec(rule[i].regex, &r->uri, matches, rule[i].msize);
+ rc = ngx_regex_exec(rule[i].regex, &r->uri,
+ captures, rule[i].ncaptures);
- if (rc == NGX_DECLINED) {
+ if (rc == NGX_REGEX_NO_MATCHED) {
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
"\"%V\" does not match \"%V\"",
@@ -174,7 +176,7 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
uri.len = rule[i].size;
for (n = 1; n < (ngx_uint_t) rc; n++) {
- uri.len += matches[2 * n + 1] - matches[2 * n];
+ uri.len += captures[2 * n + 1] - captures[2 * n];
}
if (!(uri.data = ngx_palloc(r->pool, uri.len))) {
@@ -198,11 +200,13 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
} else { /* NGX_HTTP_REWRITE_COPY_MATCH */
m = 2 * op[n].data;
- p = ngx_cpymem(p, &r->uri.data[matches[m]],
- matches[m + 1] - matches[m]);
+ p = ngx_cpymem(p, &r->uri.data[captures[m]],
+ captures[m + 1] - captures[m]);
}
}
+ uri.len = p - uri.data;
+
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
"rewritten uri: \"%V\"", &uri);
@@ -309,7 +313,7 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
u_char *data, *p;
size_t len;
ngx_str_t *value, err;
- ngx_uint_t i;
+ ngx_uint_t i, n;
ngx_http_rewrite_op_t *op;
ngx_http_rewrite_rule_t *rule;
u_char errstr[NGX_MAX_CONF_ERRSTR];
@@ -321,7 +325,7 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
ngx_init_array(rule->ops, cf->pool, 5, sizeof(ngx_http_rewrite_op_t),
NGX_CONF_ERROR);
- rule->msize = 0;
+ rule->ncaptures = 0;
rule->size = 0;
rule->status = 0;
rule->last = 0;
@@ -371,8 +375,8 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
op->op = NGX_HTTP_REWRITE_COPY_MATCH;
op->data = value[2].data[++i] - '0';
- if (rule->msize < op->data) {
- rule->msize = op->data;
+ if (rule->ncaptures < op->data) {
+ rule->ncaptures = op->data;
}
i++;
@@ -414,9 +418,22 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
}
}
- if (rule->msize) {
- rule->msize++;
- rule->msize *= 3;
+ n = ngx_regex_capture_count(rule->regex);
+
+ if (rule->ncaptures > n) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "pattern \"%V\" has less captures "
+ "than referrenced in substitution \"%V\"",
+ &value[1], &value[2]);
+ return NGX_CONF_ERROR;
+ }
+
+ if (rule->ncaptures < n) {
+ rule->ncaptures = n;
+ }
+
+ if (rule->ncaptures) {
+ rule->ncaptures = (rule->ncaptures + 1) * 3;
}
if (cf->args->nelts > 3) {
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 7a1c03ce3..3e9383e53 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -1351,6 +1351,7 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
lcf->upstream->port_text = inet_upstream.port_text;
lcf->upstream->uri = inet_upstream.uri;
lcf->upstream->uri_separator = "";
+ lcf->upstream->default_port = inet_upstream.default_port;
}
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 9429ea6db..f2f69f4df 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -678,7 +678,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
n = ngx_regex_exec(clcfp[i]->regex, &r->uri, NULL, 0);
- if (n == NGX_DECLINED) {
+ if (n == NGX_REGEX_NO_MATCHED) {
continue;
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 9aaf9bf8b..2e5459d9c 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1034,7 +1034,7 @@ static void ngx_http_upstream_finalize_request(ngx_http_request_t *r,
r->connection->log->handler = u->saved_handler;
}
- if (u->pipe.temp_file->file.fd) {
+ if (u->pipe.temp_file) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http upstream temp fd: %d",
u->pipe.temp_file->file.fd);
@@ -1048,7 +1048,7 @@ static void ngx_http_upstream_finalize_request(ngx_http_request_t *r,
}
#endif
- if (u->pipe.temp_file->file.fd) {
+ if (u->pipe.temp_file) {
r->file.fd = u->pipe.temp_file->file.fd;
#if 0