diff src/http/modules/proxy/ngx_http_proxy_handler.c @ 50:72eb30262aac NGINX_0_1_25

nginx 0.1.25 *) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author Igor Sysoev <http://sysoev.ru>
date Sat, 19 Mar 2005 00:00:00 +0300
parents a39d1b793287
children 0d75d65c642f
line wrap: on
line diff
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -11,7 +11,9 @@
 
 
 static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r);
+#if 0
 static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p);
+#endif
 
 static size_t ngx_http_proxy_log_proxy_state_getlen(ngx_http_request_t *r,
                                                     uintptr_t data);
@@ -33,8 +35,6 @@ static char *ngx_http_proxy_merge_loc_co
 
 static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
                                      void *conf);
-static char *ngx_http_proxy_parse_upstream(ngx_str_t *url,
-                                           ngx_http_proxy_upstream_conf_t *u);
 
 static char *ngx_http_proxy_set_x_var(ngx_conf_t *cf, ngx_command_t *cmd,
                                       void *conf);
@@ -362,13 +362,20 @@ static ngx_str_t cache_reasons[] = {
 };
 
 
+static ngx_str_t ngx_http_proxy_uri = ngx_string("/");
+
+
 static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r)
 {
     ngx_http_proxy_ctx_t  *p;
 
-    ngx_http_create_ctx(r, p, ngx_http_proxy_module,
-                        sizeof(ngx_http_proxy_ctx_t),
-                        NGX_HTTP_INTERNAL_SERVER_ERROR);
+    p = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t));
+    if (p == NULL) {
+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
+
+    ngx_http_set_ctx(r, p, ngx_http_proxy_module);
+
 
     p->lcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
     p->request = r;
@@ -382,7 +389,8 @@ static ngx_int_t ngx_http_proxy_handler(
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    if (!(p->state = ngx_array_push(&p->states))) {
+    p->state = ngx_array_push(&p->states);
+    if (p->state == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
@@ -439,7 +447,8 @@ static ngx_int_t ngx_http_proxy_cache_ge
     u = p->lcf->upstream;
 
     ctx.key.len = u->url.len + r->uri.len - u->location->len + r->args.len;
-    if (!(ctx.key.data = ngx_palloc(r->pool, ctx.key.len))) {
+    ctx.key.data = ngx_palloc(r->pool, ctx.key.len);
+    if (ctx.key.data == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
@@ -1072,7 +1081,8 @@ static void *ngx_http_proxy_create_loc_c
 {
     ngx_http_proxy_loc_conf_t  *conf;
 
-    if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t)))) {
+    conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t));
+    if (conf == NULL) {
         return NGX_CONF_ERROR;
     }
 
@@ -1332,7 +1342,8 @@ static char *ngx_http_proxy_set_pass(ngx
         unix_upstream.url.data = url->data + 7;
         unix_upstream.uri_part = 1;
 
-        if (!(lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream))) {
+        lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream);
+        if (lcf->peers == NULL) {
             return NGX_CONF_ERROR;
         }
 
@@ -1359,7 +1370,8 @@ static char *ngx_http_proxy_set_pass(ngx
         inet_upstream.default_port_value = 80;
         inet_upstream.uri_part = 1;
 
-        if (!(lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream))) {
+        lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream);
+        if (lcf->peers == NULL) {
             return NGX_CONF_ERROR;
         }
 
@@ -1372,8 +1384,13 @@ static char *ngx_http_proxy_set_pass(ngx
 
     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
 
+    clcf->handler = ngx_http_proxy_handler;
+
+#if (NGX_PCRE)
+    lcf->upstream->location = clcf->regex ? &ngx_http_proxy_uri : &clcf->name;
+#else
     lcf->upstream->location = &clcf->name;
-    clcf->handler = ngx_http_proxy_handler;
+#endif
 
     if (clcf->name.data[clcf->name.len - 1] == '/') {
         clcf->auto_redirect = 1;
@@ -1409,7 +1426,8 @@ static char *ngx_http_proxy_set_x_var(ng
     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->x_vars))) {
+            index = ngx_array_push(lcf->x_vars);
+            if (index == NULL) {
                 return NGX_CONF_ERROR;
             }