nginx-0.3.42-RELEASE import

    *) Feature: the "bind" option of the "listen" directive in IMAP/POP3
       proxy.

    *) Bugfix: if the same capture in the "rewrite" directive was used more
       then once.

    *) Bugfix: the $sent_http_content_type, $sent_http_content_length,
       $sent_http_last_modified, $sent_http_connection,
       $sent_http_keep_alive, and $sent_http_transfer_encoding variables
       were not written to access log.

    *) Bugfix: the $sent_http_cache_control returned value of the single
       "Cache-Control" response header line.
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 615ae75..d801e2c 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -201,11 +201,11 @@
 }
 
 
-static
-void ngx_http_init_request(ngx_event_t *rev)
+static void
+ngx_http_init_request(ngx_event_t *rev)
 {
-    ngx_uint_t                  i;
     socklen_t                   len;
+    ngx_uint_t                  i;
     struct sockaddr_in          sin;
     ngx_connection_t           *c;
     ngx_http_request_t         *r;
@@ -274,7 +274,7 @@
 
     /* AF_INET only */
 
-    hip = c->servers;
+    hip = c->listening->servers;
     hia = hip->addrs;
 
     r->port = hip->port;
@@ -311,7 +311,7 @@
             r->in_addr = sin.sin_addr.s_addr;
         }
 
-        /* the last in_port->addrs address is "*" */
+        /* the last address is "*" */
 
         for ( /* void */ ; i < hip->naddrs - 1; i++) {
             if (hia[i].addr == r->in_addr) {
@@ -1405,6 +1405,12 @@
         || rc == NGX_HTTP_REQUEST_TIME_OUT
         || r->connection->error)
     {
+        if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST
+            && r->headers_out.status == 0)
+        {
+            r->headers_out.status = NGX_HTTP_CLIENT_CLOSED_REQUEST;
+        }
+
         if (ngx_http_post_action(r) == NGX_OK) {
             return;
         }