diff src/http/ngx_http_upstream.c @ 54:bcb5fce0b038 NGINX_0_1_27

nginx 0.1.27 *) Feature: the "blocked" parameter of the "valid_referers" directive. *) Change: the errors while handling the request header now logged at "info" level. The server name and the "Host" and "Referer" header lines also logged. *) Change: the "Host" header line is also logged in error log. *) Feature: the proxy_pass_unparsed_uri directive. The special handling of the "://" symbols in URI, appeared in 0.1.11 version, now is canceled. *) Bugfix: nginx could not be built on FreeBSD and Linux, if the --without-ngx_http_auth_basic_module configuration parameter was used.
author Igor Sysoev <http://sysoev.ru>
date Mon, 28 Mar 2005 00:00:00 +0400
parents 0d75d65c642f
children 3050baa54a26
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1136,7 +1136,6 @@ ngx_http_upstream_log_error(ngx_log_t *l
 {
     u_char                 *p;
     ngx_int_t               escape;
-    ngx_str_t               uri;
     ngx_http_log_ctx_t     *ctx;
     ngx_http_request_t     *r;
     ngx_http_upstream_t    *u;
@@ -1148,7 +1147,7 @@ ngx_http_upstream_log_error(ngx_log_t *l
     peer = &u->peer;
 
     p = ngx_snprintf(buf, len,
-                     " while %s, client: %V, host: %V, URL: \"%V\","
+                     " while %s, client: %V, server: %V, URL: \"%V\","
                      " upstream: %V%V%s%V",
                      log->action,
                      &r->connection->addr_text,
@@ -1176,14 +1175,15 @@ ngx_http_upstream_log_error(ngx_log_t *l
                            r->uri.len - u->location->len, NGX_ESCAPE_URI);
 
             buf += r->uri.len - u->location->len + escape;
+            len -= r->uri.len - u->location->len + escape;
 
-            if (r->args.len == 0) {
-                return buf;
+            if (r->args.len) {
+                p = ngx_snprintf(buf, len, "?%V", &r->args);
+                len -= p - buf;
+                buf = p;
             }
 
-            len -= r->uri.len - u->location->len + escape;
-
-            return ngx_snprintf(buf, len, "?%V", &r->args);
+            return ngx_http_log_error_info(r, buf, len);
         }
 
         p = ngx_palloc(r->pool, r->uri.len - u->location->len + escape);
@@ -1194,17 +1194,23 @@ ngx_http_upstream_log_error(ngx_log_t *l
         ngx_escape_uri(p, r->uri.data + u->location->len,
                        r->uri.len - u->location->len, NGX_ESCAPE_URI);
 
-        uri.len = r->uri.len - u->location->len + escape;
-        uri.data = p;
+        p = ngx_cpymem(buf, p, r->uri.len - u->location->len + escape);
 
     } else {
-        uri.len = r->uri.len - u->location->len;
-        uri.data = r->uri.data + u->location->len;
-
+        p = ngx_cpymem(buf, r->uri.data + u->location->len,
+                       r->uri.len - u->location->len);
     }
 
-    return ngx_snprintf(buf, len, "%V%s%V", 
-                        &uri, r->args.len ? "?" : "", &r->args);
+    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);
 }