diff src/http/ngx_http_upstream.c @ 424:9da1d9d94d18 NGINX_0_7_24

nginx 0.7.24 *) Feature: the "if_modified_since" directive. *) Bugfix: nginx did not process a FastCGI server response, if the server send too many messages to stderr before response. *) Bugfix: the "$cookie_..." variables did not work in the SSI and the perl module.
author Igor Sysoev <http://sysoev.ru>
date Mon, 01 Dec 2008 00:00:00 +0300
parents ad0a34a8efa6
children e7dbea1ee115
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1114,62 +1114,59 @@ ngx_http_upstream_process_header(ngx_eve
 #endif
     }
 
-    n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
-
-    if (n == NGX_AGAIN) {
+    for ( ;; ) {
+
+        n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
+
+        if (n == NGX_AGAIN) {
 #if 0
-        ngx_add_timer(rev, u->read_timeout);
+            ngx_add_timer(rev, u->read_timeout);
 #endif
 
-        if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
-            ngx_http_upstream_finalize_request(r, u,
+            if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
+                ngx_http_upstream_finalize_request(r, u,
                                                NGX_HTTP_INTERNAL_SERVER_ERROR);
+                return;
+            }
+
+            return;
+        }
+
+        if (n == 0) {
+            ngx_log_error(NGX_LOG_ERR, rev->log, 0,
+                          "upstream prematurely closed connection");
+        }
+
+        if (n == NGX_ERROR || n == 0) {
+            ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
             return;
         }
 
-        return;
-    }
-
-    if (n == 0) {
-        ngx_log_error(NGX_LOG_ERR, rev->log, 0,
-                      "upstream prematurely closed connection");
-    }
-
-    if (n == NGX_ERROR || n == 0) {
-        ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
-        return;
-    }
-
-    u->buffer.last += n;
+        u->buffer.last += n;
 
 #if 0
-    u->valid_header_in = 0;
-
-    u->peer.cached = 0;
-#endif
-
-    rc = u->process_header(r);
-
-    if (rc == NGX_AGAIN) {
-#if 0
-        ngx_add_timer(rev, u->read_timeout);
+        u->valid_header_in = 0;
+
+        u->peer.cached = 0;
 #endif
 
-        if (u->buffer.pos == u->buffer.end) {
-            ngx_log_error(NGX_LOG_ERR, rev->log, 0,
-                          "upstream sent too big header");
-
-            ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);
-            return;
+        rc = u->process_header(r);
+
+        if (rc == NGX_AGAIN) {
+
+            if (u->buffer.pos == u->buffer.end) {
+                ngx_log_error(NGX_LOG_ERR, rev->log, 0,
+                              "upstream sent too big header");
+
+                ngx_http_upstream_next(r, u,
+                                       NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);
+                return;
+            }
+
+            continue;
         }
 
-        if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
-            ngx_http_upstream_finalize_request(r, u,
-                                               NGX_HTTP_INTERNAL_SERVER_ERROR);
-            return;
-        }
-
-        return;
+        break;
     }
 
     if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {