changeset 104:146eff53ab60 NGINX_0_2_6

nginx 0.2.6 *) Change: while using load-balancing the time before the failed backend retry was decreased from 60 to 10 seconds. *) Change: the "proxy_pass_unparsed_uri" was canceled, the original URI now passed, if the URI part is omitted in "proxy_pass" directive. *) Feature: the "error_page" directive supports redirects and allows more flexible to change an error code. *) Change: the charset in the "Content-Type" header line now is ignored in proxied subrequests. *) Bugfix: if the URI was changed in the "if" block and request did not found new configuration, then the ngx_http_rewrite_module rules ran again. *) Bugfix: if the "set" directive set the ngx_http_geo_module variable in some configuration part, the this variable was not available in other configuration parts and the "using uninitialized variable" error was occurred; bug appeared in 0.2.2.
author Igor Sysoev <http://sysoev.ru>
date Wed, 05 Oct 2005 00:00:00 +0400
parents acdd83ee07cb
children 531d62c2a28d
files CHANGES CHANGES.ru auto/cc/icc src/core/nginx.h src/core/ngx_inet.c src/core/ngx_unix_domain.c src/http/modules/ngx_http_charset_filter_module.c src/http/modules/ngx_http_fastcgi_module.c src/http/modules/ngx_http_proxy_module.c src/http/modules/ngx_http_rewrite_module.c src/http/ngx_http_core_module.c src/http/ngx_http_special_response.c src/http/ngx_http_upstream.c src/http/ngx_http_upstream.h src/imap/ngx_imap_auth_http_module.c src/os/unix/ngx_writev_chain.c
diffstat 16 files changed, 151 insertions(+), 157 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,27 @@
+
+Changes with nginx 0.2.6                                         05 Oct 2005
+
+    *) Change: while using load-balancing the time before the failed 
+       backend retry was decreased from 60 to 10 seconds.
+
+    *) Change: the "proxy_pass_unparsed_uri" was canceled, the original URI 
+       now passed, if the URI part is omitted in "proxy_pass" directive.
+
+    *) Feature: the "error_page" directive supports redirects and allows 
+       more flexible to change an error code.
+
+    *) Change: the charset in the "Content-Type" header line now is ignored 
+       in proxied subrequests.
+
+    *) Bugfix: if the URI was changed in the "if" block and request did not 
+       found new configuration, then the ngx_http_rewrite_module rules ran 
+       again.
+
+    *) Bugfix: if the "set" directive set the ngx_http_geo_module variable 
+       in some configuration part, the this variable was not available in 
+       other configuration parts and the "using uninitialized variable" 
+       error was occurred; bug appeared in 0.2.2.
+
 
 Changes with nginx 0.2.5                                         04 Oct 2005
 
@@ -10,7 +34,7 @@ Changes with nginx 0.2.5                
        the "include" command.
 
     *) Feature: the ngx_http_ssi_module supports the variable value 
-       substitutions in epxiressions of the "if" command.
+       substitutions in expressions of the "if" command.
 
 
 Changes with nginx 0.2.4                                         03 Oct 2005
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,8 +1,34 @@
+
+Изменения в nginx 0.2.6                                           05.10.2005
+
+    *) Изменение: с 60 до 10 секунд уменьшено время повторного обращения к 
+       бэкенду при использовании распределения нагрузки.
+
+    *) Изменение: директива proxy_pass_unparsed_uri упразднена, 
+       оригинальный запрос теперь передаётся, если в директиве proxy_pass 
+       отсутствует URI.
+
+    *) Добавление: директива error_page поддерживает редиректы и позволяет 
+       более гибко менять код ошибки.
+
+    *) Изменение: в проксированных подзапросах теперь игнорируется 
+       переданный charset.
+
+    *) Исправление: если после изменения URI в блоке if для запроса не 
+       находилась новая конфигурация, то правила модуля 
+       ngx_http_rewrite_module выполнялись снова.
+
+    *) Исправление: если директива set устанавливала переменную модуля 
+       ngx_http_geo_module в какой-либо части конфигурации, то эта 
+       переменная не была доступна в других частях конфигурации и 
+       выдавалась ошибка "using uninitialized variable"; ошибка появилась в 
+       0.2.2.
+
 
 Изменения в nginx 0.2.5                                           04.10.2005
 
     *) Изменение: дублирующее значение переменной модуля 
-       ngx_http_geo_module теперь выдаёт предупреждение и изменяёт старое 
+       ngx_http_geo_module теперь выдаёт предупреждение и изменяет старое 
        значение.
 
     *) Добавление: модуль ngx_http_ssi_module поддерживает команду set.
--- a/auto/cc/icc
+++ b/auto/cc/icc
@@ -90,9 +90,11 @@ CFLAGS="$CFLAGS -wd981"
 CFLAGS="$CFLAGS -wd1418"
 # external declaration in primary source file
 CFLAGS="$CFLAGS -wd1419"
+# explicit conversion of a 64-bit integral type to a smaller integral type
+CFLAGS="$CFLAGS -wd1683"
 
 case "$NGX_ICC_VER" in
-    8.*)
+    8.* | 9.*)
         # "cc" clobber ignored, warnings for Liunx's htons()
         CFLAGS="$CFLAGS -wd1469"
 
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.2.5"
+#define NGINX_VER          "nginx/0.2.6"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_OLDPID_EXT     ".oldbin"
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -346,7 +346,7 @@ ngx_inet_upstream_parse(ngx_conf_t *cf, 
 
             peers->peer[i].weight = 1;
             peers->peer[i].max_fails = 1;
-            peers->peer[i].fail_timeout = 60;
+            peers->peer[i].fail_timeout = 10;
         }
 
     } else {
@@ -471,7 +471,8 @@ ngx_inet_parse_host_port(ngx_inet_upstre
 
     } else {
         if (u->port_text.len == 0) {
-            return "no URI";
+            u->default_port = 1;
+            return NULL;
         }
 
         port = ngx_atoi(u->port_text.data, u->port_text.len);
--- a/src/core/ngx_unix_domain.c
+++ b/src/core/ngx_unix_domain.c
@@ -34,13 +34,6 @@ ngx_unix_upstream_parse(ngx_conf_t *cf, 
                 break;
             }
         }
-
-        if (u->uri.len == 0) {
-            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                               "the unix domain upstream \"%V\" has no URI",
-                               &u->name);
-            return NULL;
-        }
     }
 
     if (len == 0) {
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -162,7 +162,8 @@ ngx_http_charset_header_filter(ngx_http_
         return ngx_http_next_header_filter(r);
     }
 
-    if (ngx_strstr(r->headers_out.content_type.data, "charset") != NULL)
+    if (r->main == r
+        && ngx_strstr(r->headers_out.content_type.data, "charset") != NULL)
     {
         return ngx_http_next_header_filter(r);
     }
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -148,11 +148,6 @@ static ngx_str_t  ngx_http_fastcgi_scrip
     ngx_string("fastcgi_script_name");
 
 
-#if (NGX_PCRE)
-static ngx_str_t ngx_http_fastcgi_uri = ngx_string("/");
-#endif
-
-
 static ngx_conf_post_t  ngx_http_fastcgi_lowat_post =
     { ngx_http_fastcgi_lowat_check };
 
@@ -1448,7 +1443,6 @@ ngx_http_fastcgi_create_loc_conf(ngx_con
     conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; 
     conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
 
-    conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET;
     conf->upstream.method = NGX_CONF_UNSET_UINT;
     conf->upstream.pass_request_headers = NGX_CONF_UNSET;
     conf->upstream.pass_request_body = NGX_CONF_UNSET;
@@ -1602,16 +1596,6 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf
                               NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0,
                               ngx_garbage_collector_temp_handler, cf);
 
-    ngx_conf_merge_value(conf->upstream.pass_unparsed_uri,
-                              prev->upstream.pass_unparsed_uri, 0);
-
-    if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) {
-        ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
-                      "\"fastcgi_pass_unparsed_uri\" can be set for "
-                      "location \"/\" or given by regular expression.");
-        return NGX_CONF_ERROR;
-    }
-
     if (conf->upstream.method == NGX_CONF_UNSET_UINT) {
         conf->upstream.method = prev->upstream.method; 
     }
@@ -1812,6 +1796,10 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ng
     ngx_unix_domain_upstream_t   unix_upstream;
 #endif
 
+    if (lcf->upstream.schema.len) {
+        return "is duplicate";
+    }
+
     value = cf->args->elts;
 
     if (ngx_strncasecmp(value[1].data, "unix:", 5) == 0) {
@@ -1828,6 +1816,8 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ng
             return NGX_CONF_ERROR;
         }
 
+        lcf->peers->peer[0].uri_separator = "";
+
 #else
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "the unix domain sockets are not supported "
@@ -1850,18 +1840,12 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ng
 
     lcf->upstream.schema.len = sizeof("fastcgi://") - 1;
     lcf->upstream.schema.data = (u_char *) "fastcgi://";
-    lcf->upstream.uri.len = sizeof("/") - 1;
-    lcf->upstream.uri.data = (u_char *) "/";
 
     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
 
     clcf->handler = ngx_http_fastcgi_handler;
 
-#if (NGX_PCRE)
-    lcf->upstream.location = clcf->regex ? &ngx_http_fastcgi_uri : &clcf->name;
-#else
     lcf->upstream.location = &clcf->name;
-#endif
 
     if (clcf->name.data[clcf->name.len - 1] == '/') {
         clcf->auto_redirect = 1;
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -159,13 +159,6 @@ static ngx_command_t  ngx_http_proxy_com
       offsetof(ngx_http_proxy_loc_conf_t, upstream.redirect_errors),
       NULL },
 
-    { ngx_string("proxy_pass_unparsed_uri"),
-      NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
-      ngx_conf_set_flag_slot,
-      NGX_HTTP_LOC_CONF_OFFSET,
-      offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_unparsed_uri),
-      NULL },
-
     { ngx_string("proxy_set_header"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
       ngx_conf_set_table_elt_slot,
@@ -342,11 +335,6 @@ static ngx_http_variable_t  ngx_http_pro
 };
 
 
-#if (NGX_PCRE)
-static ngx_str_t ngx_http_proxy_uri = ngx_string("/");
-#endif
-
-
 static ngx_int_t
 ngx_http_proxy_handler(ngx_http_request_t *r)
 {   
@@ -432,7 +420,7 @@ ngx_http_proxy_create_request(ngx_http_r
 
     loc_len = r->valid_location ? u->conf->location->len : 0;
 
-    if (plcf->upstream.pass_unparsed_uri && r->valid_unparsed_uri) {
+    if (u->conf->uri.len == 0 && r->valid_unparsed_uri) {
         len += r->unparsed_uri.len;
 
     } else {
@@ -514,11 +502,15 @@ ngx_http_proxy_create_request(ngx_http_r
                              r->method_name.len + 1);
     }
 
-    if (plcf->upstream.pass_unparsed_uri && r->valid_unparsed_uri) {
+    u->uri.data = b->last;
+
+    if (u->conf->uri.len == 0 && r->valid_unparsed_uri) {
         b->last = ngx_cpymem(b->last, r->unparsed_uri.data,
                              r->unparsed_uri.len);
     } else {
-        b->last = ngx_cpymem(b->last, u->conf->uri.data, u->conf->uri.len);
+        if (r->valid_location) {
+            b->last = ngx_cpymem(b->last, u->conf->uri.data, u->conf->uri.len);
+        }
 
         if (escape) {
             ngx_escape_uri(b->last, r->uri.data + loc_len,
@@ -536,6 +528,8 @@ ngx_http_proxy_create_request(ngx_http_r
         }
     }
 
+    u->uri.len = b->last - u->uri.data;
+
     b->last = ngx_cpymem(b->last, ngx_http_proxy_version,
                          sizeof(ngx_http_proxy_version) - 1);
 
@@ -1312,7 +1306,6 @@ ngx_http_proxy_create_loc_conf(ngx_conf_
     conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;  
     conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
 
-    conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET;
     conf->upstream.method = NGX_CONF_UNSET_UINT;
     conf->upstream.pass_request_headers = NGX_CONF_UNSET;
     conf->upstream.pass_request_body = NGX_CONF_UNSET;
@@ -1467,16 +1460,6 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t
                               NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0,
                               ngx_garbage_collector_temp_handler, cf);
 
-    ngx_conf_merge_value(conf->upstream.pass_unparsed_uri,
-                              prev->upstream.pass_unparsed_uri, 0);
-
-    if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) {
-        ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
-                      "\"proxy_pass_unparsed_uri\" can be set for "
-                      "location \"/\" or given by regular expression.");
-        return NGX_CONF_ERROR;
-    }
-
     if (conf->upstream.method == NGX_CONF_UNSET_UINT) {
         conf->upstream.method = prev->upstream.method;
     }
@@ -1759,7 +1742,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
 {
     ngx_http_proxy_loc_conf_t *plcf = conf;
 
-    ngx_uint_t                   i;
     ngx_str_t                   *value, *url;
     ngx_inet_upstream_t          inet_upstream;
     ngx_http_core_loc_conf_t    *clcf;
@@ -1767,6 +1749,10 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
     ngx_unix_domain_upstream_t   unix_upstream;
 #endif
 
+    if (plcf->upstream.schema.len) {
+        return "is duplicate";
+    }
+
     value = cf->args->elts;
 
     url = &value[1];
@@ -1792,8 +1778,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
             return NGX_CONF_ERROR;
         }
 
-        plcf->peers->peer[0].uri_separator = ":";
-
         plcf->host_header.len = sizeof("localhost") - 1;
         plcf->host_header.data = (u_char *) "localhost";
         plcf->upstream.uri = unix_upstream.uri;
@@ -1820,10 +1804,6 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
             return NGX_CONF_ERROR;
         }
 
-        for (i = 0; i < plcf->peers->number; i++) {
-            plcf->peers->peer[i].uri_separator = "";
-        }
-
         plcf->host_header = inet_upstream.host_header;
         plcf->port_text = inet_upstream.port_text;
         plcf->upstream.uri = inet_upstream.uri;
@@ -1836,10 +1816,17 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
 
     clcf->handler = ngx_http_proxy_handler;
 
+    plcf->upstream.location = &clcf->name;
+
 #if (NGX_PCRE)
-    plcf->upstream.location = clcf->regex ? &ngx_http_proxy_uri : &clcf->name;
-#else
-    plcf->upstream.location = &clcf->name;
+
+    if (clcf->regex && plcf->upstream.uri.len) {
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           "\"proxy_pass\" may not have URI part in "
+                           "location given by regular expression");
+        return NGX_CONF_ERROR;
+    }
+
 #endif
 
     plcf->upstream.url = *url;
--- a/src/http/modules/ngx_http_rewrite_module.c
+++ b/src/http/modules/ngx_http_rewrite_module.c
@@ -691,7 +691,7 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_
 
     if (pclcf->locations.elts == NULL) {
         if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *))
-                                                                  == NGX_ERROR)
+            == NGX_ERROR)
         {
             return NGX_CONF_ERROR;
         }
@@ -759,6 +759,10 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_
     if_code->next = (u_char *) lcf->codes->elts + lcf->codes->nelts
                                                 - (u_char *) if_code;
 
+    /* the code array belong to parent block */
+
+    nlcf->codes = NULL;
+
     return NGX_CONF_OK;
 }
 
@@ -1048,8 +1052,10 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx
         return NGX_CONF_ERROR;
     }
 
-    v->handler = ngx_http_rewrite_var;
-    v->data = index;
+    if (v->handler == NULL) {
+        v->handler = ngx_http_rewrite_var;
+        v->data = index;
+    }
 
     n = ngx_http_script_variables_count(&value[2]);
 
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -626,6 +626,11 @@ ngx_http_find_location_config(ngx_http_r
         return NGX_HTTP_NOT_FOUND;
     }
 
+    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "using configuration \"%s%V\"",
+                   (clcf->noname ? "*" : (clcf->exact_match ? "=" : "")),
+                   &clcf->name);
+
     ngx_http_update_location_config(r);
 
     ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -708,7 +713,8 @@ ngx_http_core_find_location(ngx_http_req
     ngx_uint_t                 i, found, noregex;
     ngx_http_core_loc_conf_t  *clcf, **clcfp;
 
-    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "find location");
+    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "find location for \"%V\"", &r->uri);
 
     found = 0;
     noregex = 0;
@@ -907,7 +913,7 @@ ngx_http_set_content_type(ngx_http_reque
 ngx_int_t
 ngx_http_send_header(ngx_http_request_t *r)
 {
-    if (r->err_ctx) {
+    if (r->err_status) {
         r->headers_out.status = r->err_status;
         r->headers_out.status_line.len = 0;
     }
@@ -2237,18 +2243,23 @@ ngx_http_core_error_page(ngx_conf_t *cf,
             return NGX_CONF_ERROR;
         }
 
-        overwrite = ngx_atoi(&value[i].data[1], value[i].len - 1);
-
-        if (overwrite == NGX_ERROR) {
-            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                               "invalid value \"%V\"", &value[i]);
-            return NGX_CONF_ERROR;
+        if (value[i].len > 1) {
+            overwrite = ngx_atoi(&value[i].data[1], value[i].len - 1);
+
+            if (overwrite == NGX_ERROR) {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "invalid value \"%V\"", &value[i]);
+                return NGX_CONF_ERROR;
+            }
+
+        } else {
+            overwrite = 0;
         }
 
         n = 2;
 
     } else {
-        overwrite = 0;
+        overwrite = -1;
         n = 1;
     }
 
@@ -2273,7 +2284,8 @@ ngx_http_core_error_page(ngx_conf_t *cf,
             return NGX_CONF_ERROR;
         }
 
-        err->overwrite = overwrite;
+        err->overwrite = (overwrite >= 0) ? overwrite : err->status;
+
         err->uri = value[cf->args->nelts - 1];
     }
 
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -283,18 +283,31 @@ ngx_http_special_response_handler(ngx_ht
         for (i = 0; i < clcf->error_pages->nelts; i++) {
 
             if (err_page[i].status == error) {
-
-                if (err_page[i].overwrite) {
-                    r->err_status = err_page[i].overwrite;
-                } else {
-                    r->err_status = error;
-                }
-
+                r->err_status = err_page[i].overwrite;
                 r->err_ctx = r->ctx;
 
                 r->method = NGX_HTTP_GET;
 
-                return ngx_http_internal_redirect(r, &err_page[i].uri, NULL);
+                if (err_page[i].uri.data[0] == '/') {
+                    return ngx_http_internal_redirect(r, &err_page[i].uri,
+                                                      NULL);
+                }
+
+                r->headers_out.location =
+                                        ngx_list_push(&r->headers_out.headers);
+
+                if (r->headers_out.location) {
+                    r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
+                    error = NGX_HTTP_MOVED_TEMPORARILY;
+
+                    r->headers_out.location->hash = 1;
+                    r->headers_out.location->key.len = sizeof("Location") - 1;
+                    r->headers_out.location->key.data = (u_char *) "Location";
+                    r->headers_out.location->value = err_page[i].uri;
+
+                } else {
+                    error = NGX_HTTP_INTERNAL_SERVER_ERROR;
+                }
             }
         }
     }
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1793,8 +1793,6 @@ static u_char *
 ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len)
 {
     u_char                 *p;
-    ngx_str_t               line;
-    uintptr_t               escape;
     ngx_http_upstream_t    *u;
     ngx_peer_connection_t  *peer;
 
@@ -1809,62 +1807,10 @@ ngx_http_upstream_log_error(ngx_http_req
                      &u->conf->schema,
                      &peer->peers->peer[peer->cur_peer].name,
                      peer->peers->peer[peer->cur_peer].uri_separator,
-                     &u->conf->uri);
+                     &u->uri);
     len -= p - buf;
     buf = p;
 
-    if (r->quoted_uri) {
-        escape = 2 * ngx_escape_uri(NULL, r->uri.data + u->conf->location->len,
-                                    r->uri.len - u->conf->location->len,
-                                    NGX_ESCAPE_URI);
-    } else {
-        escape = 0;
-    }
-
-    if (escape) {
-        if (len >= r->uri.len - u->conf->location->len + escape) {
-
-            ngx_escape_uri(buf, r->uri.data + u->conf->location->len,
-                           r->uri.len - u->conf->location->len, NGX_ESCAPE_URI);
-
-            buf += r->uri.len - u->conf->location->len + escape;
-            len -= r->uri.len - u->conf->location->len + escape;
-
-        } else {
-            p = ngx_palloc(r->pool,
-                           r->uri.len - u->conf->location->len + escape);
-            if (p == NULL) {
-                return buf;
-            }
-
-            ngx_escape_uri(p, r->uri.data + u->conf->location->len,
-                           r->uri.len - u->conf->location->len, NGX_ESCAPE_URI);
-
-            line.len = len;
-            line.data = p;
-
-            return ngx_snprintf(buf, len, "%V", &line);
-        }
-
-    } else {
-        line.len = r->uri.len - u->conf->location->len;
-        if (line.len > len) {
-            line.len = len;
-        }
-
-        line.data = r->uri.data + u->conf->location->len;
-        p = ngx_snprintf(buf, len, "%V", &line);
-
-        len -= p - buf;
-        buf = p;
-    }
-
-    if (r->args.len) {
-        p = ngx_snprintf(buf, len, "?%V", &r->args);
-        len -= p - buf;
-        buf = p;
-    }
-
     return ngx_http_log_error_info(r, buf, len);
 }
 
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -70,7 +70,6 @@ typedef struct {
     ngx_flag_t                      pass_request_body;
 
     ngx_flag_t                      redirect_errors;
-    ngx_flag_t                      pass_unparsed_uri;
     ngx_flag_t                      cyclic_temp_file;
 
     ngx_flag_t                      pass_x_powered_by;
@@ -164,6 +163,8 @@ struct ngx_http_upstream_s {
     ngx_http_upstream_state_t      *state;
     ngx_array_t                     states;  /* of ngx_http_upstream_state_t */
 
+    ngx_str_t                       uri;
+
     unsigned                        cachable:1;
     unsigned                        accel:1;
 
--- a/src/imap/ngx_imap_auth_http_module.c
+++ b/src/imap/ngx_imap_auth_http_module.c
@@ -1068,7 +1068,6 @@ ngx_imap_auth_http(ngx_conf_t *cf, ngx_c
 {   
     ngx_imap_auth_http_conf_t *ahcf = conf;
 
-    ngx_uint_t                   i;
     ngx_str_t                   *value, *url;
     ngx_inet_upstream_t          inet_upstream;
 #if (NGX_HAVE_UNIX_DOMAIN)
@@ -1094,8 +1093,6 @@ ngx_imap_auth_http(ngx_conf_t *cf, ngx_c
             return NGX_CONF_ERROR;
         }
 
-        ahcf->peers->peer[0].uri_separator = ":";
-
         ahcf->host_header.len = sizeof("localhost") - 1;
         ahcf->host_header.data = (u_char *) "localhost";
         ahcf->uri = unix_upstream.uri;
@@ -1121,13 +1118,14 @@ ngx_imap_auth_http(ngx_conf_t *cf, ngx_c
             return NGX_CONF_ERROR;
         }
 
-        for (i = 0; i < ahcf->peers->number; i++) {
-            ahcf->peers->peer[i].uri_separator = "";
-        }
-
         ahcf->host_header = inet_upstream.host_header;
         ahcf->uri = inet_upstream.uri;
     }
 
+    if (ahcf->uri.len) {
+        ahcf->uri.len = sizeof("/") - 1;
+        ahcf->uri.data = (u_char *) "/";
+    }
+
     return NGX_CONF_OK;
 }
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -81,7 +81,7 @@ ngx_writev_chain(ngx_connection_t *c, ng
             size = cl->buf->last - cl->buf->pos;
 
             if (send + size > limit) {
-                size = limit - send;
+                size = (ssize_t) limit - send;
             }
 
             if (prev == cl->buf->pos) {