nginx-0.0.1-2003-12-08-23:48:12 import
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index e8b78f4..84396a9 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -384,7 +384,7 @@
     ngx_connection_t      *c;
     ngx_http_request_t    *r;
     ngx_http_proxy_ctx_t  *p;
-    
+
     ngx_log_debug(rev->log, "busy lock");
 
     c = rev->data;
@@ -594,7 +594,7 @@
         *buf++ = '-';
 
     } else {
-        buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expired);
+        buf += ngx_snprintf(buf, NGX_TIME_T_LEN, TIME_T_FMT, p->state->expired);
     }
 
     *buf++ = '/';
@@ -603,7 +603,7 @@
         *buf++ = '-';
 
     } else {
-        buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->bl_time);
+        buf += ngx_snprintf(buf, NGX_TIME_T_LEN, TIME_T_FMT, p->state->bl_time);
     }
 
     *buf++ = '/';
@@ -635,7 +635,7 @@
         *buf++ = '-';
 
     } else {
-        buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expires);
+        buf += ngx_snprintf(buf, NGX_TIME_T_LEN, TIME_T_FMT, p->state->expires);
     }
 
     *buf++ = ' ';
diff --git a/src/http/modules/proxy/ngx_http_proxy_header.c b/src/http/modules/proxy/ngx_http_proxy_header.c
index 76d3321..0c44a52 100644
--- a/src/http/modules/proxy/ngx_http_proxy_header.c
+++ b/src/http/modules/proxy/ngx_http_proxy_header.c
@@ -23,7 +23,7 @@
         if (&h[i] == headers_in->connection) {
             continue;
         }
-    
+
         if (p->accel) {
             if (&h[i] == headers_in->date
                 || &h[i] == headers_in->accept_ranges) {
@@ -34,12 +34,12 @@
                 && !p->lcf->pass_x_accel_expires)
             {
                 continue;
-            } 
-    
+            }
+
             if (&h[i] == headers_in->server && !p->lcf->pass_server) {
                 continue;
-            } 
-    
+            }
+
             if (&h[i] == headers_in->location) {
                 if (ngx_http_proxy_rewrite_location_header(p, &h[i])
                                                                   == NGX_ERROR)
@@ -48,9 +48,9 @@
                 }
 
                 continue;
-            } 
+            }
         }
-    
+
         if (&h[i] == headers_in->content_type) {
             r->headers_out.content_type = &h[i];
             r->headers_out.content_type->key.len = 0;
@@ -61,9 +61,9 @@
         {
             return NGX_ERROR;
         }
-    
+
         *ho = h[i];
-    
+
         /*
          * ngx_http_header_filter() does not handle specially
          * the following headers if they are set:
@@ -122,7 +122,7 @@
     r->headers_out.location->value.len = uc->location->len
                                          + (loc->value.len - uc->url.len) + 1;
     r->headers_out.location->value.data =
-                       ngx_palloc(r->pool, r->headers_out.location->value.len); 
+                       ngx_palloc(r->pool, r->headers_out.location->value.len);
 
     if (r->headers_out.location->value.data == NULL) {
         return NGX_ERROR;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 547e028..2f5c923 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1354,12 +1354,14 @@
 {
     ngx_http_core_loc_conf_t *lcf = conf;
 
+#if 0
     ngx_str_t  *value;
 
     value = cf->args->elts;
+#endif
 
     ngx_test_null(lcf->err_log,
-                  ngx_log_create_errlog(cf->cycle, &value[1]),
+                  ngx_log_create_errlog(cf->cycle, cf->args),
                   NGX_CONF_ERROR);
 
     return NGX_CONF_OK;
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index 6e39f45..49f1dba 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -158,8 +158,7 @@
 
     if (r->headers_out.content_length == NULL) {
         if (r->headers_out.content_length_n >= 0) {
-                                           /* 2^64 */
-            len += sizeof("Content-Length: 18446744073709551616" CRLF) - 1;
+            len += sizeof("Content-Length: ") - 1 + NGX_OFF_T_LEN + 2;
         }
     }
 
@@ -238,49 +237,18 @@
 
     if (!(r->headers_out.date && r->headers_out.date->key.len)) {
         h->last = ngx_cpymem(h->last, "Date: ", sizeof("Date: ") - 1);
-#if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
-        p = h->last;
-#endif
         h->last = ngx_cpymem(h->last, ngx_cached_http_time.data,
                              ngx_cached_http_time.len);
 
-#if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
-        r->headers_out.date = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));
-        if (r->headers_out.date == NULL) {
-            return NGX_ERROR;
-        }
-
-        r->headers_out.date->key.len = 0;
-        r->headers_out.date->key.data = NULL;
-        r->headers_out.date->value.len = h->last - p;
-        r->headers_out.date->value.data = p;
-#endif
-
         *(h->last++) = CR; *(h->last++) = LF;
     }
 
     if (r->headers_out.content_length == NULL) {
         if (r->headers_out.content_length_n >= 0) {
-#if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
-            p = h->last + sizeof("Content-Length: ") - 1;
-#endif
-            h->last += ngx_snprintf(h->last,        /* 2^64 */
-                            sizeof("Content-Length: 18446744073709551616" CRLF),
-                            "Content-Length: " OFF_T_FMT CRLF,
-                            r->headers_out.content_length_n);
-
-#if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
-            r->headers_out.content_length = ngx_palloc(r->pool,
-                                                       sizeof(ngx_table_elt_t));
-            if (r->headers_out.content_length == NULL) {
-                return NGX_ERROR;
-            }
-
-            r->headers_out.content_length->key.len = 0;
-            r->headers_out.content_length->key.data = NULL;
-            r->headers_out.content_length->value.len = h->last - p - 2;
-            r->headers_out.content_length->value.data = p;
-#endif
+            h->last += ngx_snprintf(h->last,
+                                sizeof("Content-Length: ") + NGX_OFF_T_LEN + 2,
+                                "Content-Length: " OFF_T_FMT CRLF,
+                                r->headers_out.content_length_n);
         }
     }
 
@@ -332,24 +300,8 @@
     {
         h->last = ngx_cpymem(h->last, "Last-Modified: ",
                              sizeof("Last-Modified: ") - 1);
-#if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
-        p = h->last;
-#endif
         h->last += ngx_http_time(h->last, r->headers_out.last_modified_time);
 
-#if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
-        r->headers_out.last_modified = ngx_palloc(r->pool,
-                                                  sizeof(ngx_table_elt_t));
-        if (r->headers_out.last_modified == NULL) {
-            return NGX_ERROR;
-        }
-
-        r->headers_out.last_modified->key.len = 0;
-        r->headers_out.last_modified->key.data = NULL;
-        r->headers_out.last_modified->value.len = h->last - p;
-        r->headers_out.last_modified->value.data = p;
-#endif
-
         *(h->last++) = CR; *(h->last++) = LF;
     }
 
diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c
index 48ebd01..ff94395 100644
--- a/src/http/ngx_http_log_handler.c
+++ b/src/http/ngx_http_log_handler.c
@@ -21,10 +21,15 @@
                                  uintptr_t data);
 static char *ngx_http_log_header_in(ngx_http_request_t *r, char *buf,
                                     uintptr_t data);
+static char *ngx_http_log_connection_header_out(ngx_http_request_t *r,
+                                                char *buf, uintptr_t data);
+static char *ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r,
+                                                       char *buf,
+                                                       uintptr_t data);
 static char *ngx_http_log_unknown_header_in(ngx_http_request_t *r, char *buf,
                                             uintptr_t data);
 static char *ngx_http_log_header_out(ngx_http_request_t *r, char *buf,
-                                    uintptr_t data);
+                                     uintptr_t data);
 static char *ngx_http_log_unknown_header_out(ngx_http_request_t *r, char *buf,
                                              uintptr_t data);
 
@@ -104,7 +109,7 @@
                           ngx_http_log_time },
     { ngx_string("request"), 0, ngx_http_log_request },
     { ngx_string("status"), 3, ngx_http_log_status },
-    { ngx_string("length"), NGX_OFF_LEN, ngx_http_log_length },
+    { ngx_string("length"), NGX_OFF_T_LEN, ngx_http_log_length },
     { ngx_string("i"), NGX_HTTP_LOG_ARG, ngx_http_log_header_in },
     { ngx_string("o"), NGX_HTTP_LOG_ARG, ngx_http_log_header_out },
     { ngx_null_string, 0, NULL }
@@ -212,18 +217,6 @@
 {
     return ngx_cpymem(buf, ngx_cached_http_log_time.data,
                       ngx_cached_http_log_time.len);
-
-#if 0
-    ngx_tm_t  tm;
-
-    ngx_localtime(&tm);
-
-    return buf + ngx_snprintf(buf, sizeof("28/Sep/1970:12:00:00"),
-                              "%02d/%s/%d:%02d:%02d:%02d",
-                              tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
-                              tm.ngx_tm_year,
-                              tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec);
-#endif
 }
 
 
@@ -250,7 +243,7 @@
 static char *ngx_http_log_length(ngx_http_request_t *r, char *buf,
                                  uintptr_t data)
 {
-    return buf + ngx_snprintf(buf, NGX_OFF_LEN + 1, OFF_T_FMT,
+    return buf + ngx_snprintf(buf, NGX_OFF_T_LEN + 1, OFF_T_FMT,
                               r->connection->sent);
 }
 
@@ -357,11 +350,36 @@
     ngx_http_log_op_t  *op;
 
     if (r) {
+
+        /* run-time execution */
+
+        if (r->http_version < NGX_HTTP_VERSION_10) {
+            if (buf) {
+                *buf = '-';
+            }
+
+            return buf + 1;
+        }
+
         h = *(ngx_table_elt_t **) ((char *) &r->headers_out + data);
 
         if (h == NULL) {
 
-            /* no header */
+            /*
+             * No header pointer was found.
+             * However, some headers: "Date", "Server", "Content-Length",
+             * and "Last-Modified" have a special handling in the header filter
+             * but we do not set up their pointers in the filter because
+             * they are too seldom needed to be logged.
+             */
+
+            if (data == offsetof(ngx_http_headers_out_t, date)) {
+                if (buf == NULL) {
+                    return (char *) ngx_cached_http_time.len;
+                }
+                return ngx_cpymem(buf, ngx_cached_http_time.data,
+                                  ngx_cached_http_time.len);
+            }
 
             if (data == offsetof(ngx_http_headers_out_t, server)) {
                 if (buf == NULL) {
@@ -370,6 +388,36 @@
                 return ngx_cpymem(buf, NGINX_VER, sizeof(NGINX_VER) - 1);
             }
 
+            if (data == offsetof(ngx_http_headers_out_t, content_length)) {
+                if (r->headers_out.content_length_n == -1) {
+                    if (buf) {
+                        *buf = '-';
+                    }
+                    return buf + 1;
+                }
+
+                if (buf == NULL) {
+                    return (char *) NGX_OFF_T_LEN;
+                }
+                return buf + ngx_snprintf(buf, NGX_OFF_T_LEN + 2, OFF_T_FMT,
+                                          r->headers_out.content_length_n);
+            }
+
+            if (data == offsetof(ngx_http_headers_out_t, last_modified)) {
+                if (r->headers_out.last_modified_time == -1) {
+                    if (buf) {
+                        *buf = '-';
+                    }
+                    return buf + 1;
+                }
+
+                if (buf == NULL) {
+                    return (char *) sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1;
+                }
+                return buf + ngx_http_time(buf,
+                                           r->headers_out.last_modified_time);
+            }
+
             if (buf) {
                 *buf = '-';
             }
@@ -406,6 +454,21 @@
         }
     }
 
+    if (s->len == sizeof("Connection") - 1
+        && ngx_strncasecmp(s->data, "Connection", s->len) == 0)
+    {
+        op->op = ngx_http_log_connection_header_out;
+        op->data = NULL;
+        return NULL;
+    }
+
+    if (s->len == sizeof("Transfer-Encoding") - 1
+        && ngx_strncasecmp(s->data, "Transfer-Encoding", s->len) == 0) {
+        op->op = ngx_http_log_transfer_encoding_header_out;
+        op->data = NULL;
+        return NULL;
+    }
+
     op->op = ngx_http_log_unknown_header_out;
     op->data = (uintptr_t) s;
 
@@ -413,6 +476,41 @@
 }
 
 
+static char *ngx_http_log_connection_header_out(ngx_http_request_t *r,
+                                                char *buf, uintptr_t data)
+{
+    if (buf == NULL) {
+        return (char *) ((r->keepalive) ? sizeof("keep-alive") - 1:
+                                          sizeof("close") - 1);
+    }
+
+    if (r->keepalive) {
+        return ngx_cpymem(buf, "keep-alive", sizeof("keep-alive") - 1);
+
+    } else {
+        return ngx_cpymem(buf, "close", sizeof("close") - 1);
+    }
+}
+
+
+static char *ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r,
+                                                       char *buf,
+                                                       uintptr_t data)
+{
+    if (buf == NULL) {
+        return (char *) ((r->chunked) ? sizeof("chunked") - 1 : 1);
+    }
+
+    if (r->chunked) {
+        return ngx_cpymem(buf, "chunked", sizeof("chunked") - 1);
+    }
+
+    *buf = '-';
+
+    return buf + 1;
+}
+
+
 static char *ngx_http_log_unknown_header_out(ngx_http_request_t *r, char *buf,
                                              uintptr_t data)
 {
diff --git a/src/http/ngx_http_log_handler.h b/src/http/ngx_http_log_handler.h
index 3d8481c..eb55f09 100644
--- a/src/http/ngx_http_log_handler.h
+++ b/src/http/ngx_http_log_handler.h
@@ -17,8 +17,8 @@
 
 /* STUB */
 #define NGX_INT32_LEN      sizeof("-2147483648") - 1
-#define NGX_TIME_LEN       sizeof("-2147483648") - 1
-#define NGX_OFF_LEN        sizeof("-9223372036854775808") - 1
+#define NGX_TIME_T_LEN     sizeof("-2147483648") - 1
+#define NGX_OFF_T_LEN      sizeof("-9223372036854775808") - 1
 
 
 typedef struct {