nginx-0.0.1-2002-12-10-21:05:12 import
diff --git a/src/http/modules/ngx_http_event_proxy_handler.c b/src/http/modules/ngx_http_event_proxy_handler.c
index b67bb25..af35468 100644
--- a/src/http/modules/ngx_http_event_proxy_handler.c
+++ b/src/http/modules/ngx_http_event_proxy_handler.c
@@ -65,8 +65,9 @@
     ngx_chain_t      *chain;
     ngx_table_elt_t  *header;
 
-    /* "+ 4" is for "\r\n" after request line and at the header end */
-    len = r->request_line.len + 4;
+    /* 2 is for "\r\n" after request line
+       and 2 is for "\r\n" at the header end */
+    len = r->request_line.len + 2 + 2;
 
     /* "Connection: close\r\n" */
     len += sizeof(conn_close) - 1;
@@ -79,8 +80,8 @@
         if (&header[i] == r->headers_in.connection)
             continue;
 
-        /* "+ 4" is for ": " and "\r\n" */
-        len += header[i].key.len + header[i].value.len + 4;
+        /* 2 is for ": " and 2 is for "\r\n" */
+        len += header[i].key.len + 2 + header[i].value.len + 2;
     }
 
     /* STUB */ len++;
@@ -320,6 +321,7 @@
         ngx_http_proxy_process_status_line(r, p)
         ngx_http_proxy_process_reponse_header(r, p) */
 
+#if 0
     do {
         rc = (p->state_handler)(r, p);
 
@@ -329,6 +331,7 @@
         /* rc == NGX_OK || rc == NGX_AGAIN */
 
     } while (p->header_in->pos.mem < p->header_in->last.mem);
+#endif
 
     ev->event_handler = ngx_http_proxy_read_response_body;
     if (p->header_in->end - p->header_in->last.mem == 0)
@@ -342,11 +345,11 @@
 {
     int  rc;
 
-    ngx_log_debug(r->connection->log, "STATUS: %d" _ p->status);
-
     rc = ngx_read_http_proxy_status_line(p);
 
-    ngx_log_debug(r->connection->log, "STATUS: %d" _ p->status);
+    if (rc == NGX_HTTP_PROXY_PARSE_NO_HEADER) {
+        p->status = 200;
+    }
 
     if (rc == NGX_OK) {
         /* STUB */
@@ -365,6 +368,11 @@
     /* STUB */ return NGX_ERROR;
 }
 
+static int ngx_http_proxy_process_response_header(ngx_http_request_t *r,
+                                                  ngx_http_proxy_ctx_t *p)
+{
+}
+
 static int ngx_http_proxy_read_response_body(ngx_event_t *ev)
 {
     int     n;
@@ -560,8 +568,10 @@
 
             ctx->status = ctx->status * 10 + ch - '0';
 
-            if (++ctx->status_count == 3)
+            if (++ctx->status_count == 3) {
                 state = sw_space_after_status;
+                ctx->status_line = p - 3;
+            }
 
             break;
 
@@ -569,7 +579,6 @@
          case sw_space_after_status:
             switch (ch) {
             case ' ':
-                ctx->status_text = p - 1;
                 state = sw_status_text;
                 break;
             case CR:
diff --git a/src/http/modules/ngx_http_event_proxy_handler.h b/src/http/modules/ngx_http_event_proxy_handler.h
index ffc3a15..596a193 100644
--- a/src/http/modules/ngx_http_event_proxy_handler.h
+++ b/src/http/modules/ngx_http_event_proxy_handler.h
@@ -30,7 +30,7 @@
     int          state;
     int          status;
     int          status_count;
-    char        *status_text;
+    char        *status_line;
     char        *request_end;
     int        (*state_handler)(ngx_http_request_t *r, ngx_http_proxy_ctx_t *p);
 };
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 6877b33..b6e0adb 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -11,17 +11,24 @@
 
 
 static void *ngx_http_index_create_conf(ngx_pool_t *pool);
-static char *ngx_http_index_set_index(ngx_pool_t *p, void *conf, char *value);
+static void *ngx_http_index_merge_conf(ngx_pool_t *p,
+                                       void *parent, void *child);
+static char *ngx_http_index_set_index(ngx_pool_t *p, void *conf,
+                                      ngx_str_t *value);
 
 static ngx_command_t ngx_http_index_commands[];
 
 
 ngx_http_module_t  ngx_http_index_module = {
     NGX_HTTP_MODULE,
+
     NULL,                                  /* create server config */
     ngx_http_index_create_conf,            /* create location config */
     ngx_http_index_commands,               /* module directives */
+
     NULL,                                  /* init module */
+    NULL,                                  /* translate handler */
+
     NULL,                                  /* init output body filter */
 };
 
@@ -36,32 +43,32 @@
 
 };
 
+
 int ngx_http_index_handler(ngx_http_request_t *r)
 {
-    int          index_len, i;
-    char        *name, *loc, *file;
+    int          i;
+    char        *name, *file;
+    ngx_str_t    loc, *index;
     ngx_err_t    err;
     ngx_fd_t     fd;
 
-    ngx_http_index_file_t  *index;
     ngx_http_index_conf_t  *cf;
 
     cf = (ngx_http_index_conf_t *)
                             ngx_get_module_loc_conf(r, ngx_http_index_module);
 
-    index_len = (*(r->uri_end - 1) == '/') ? cf->max_index_len : 0;
-
     ngx_test_null(name,
-                  ngx_palloc(r->pool, r->uri_end - r->uri_start + index_len
-                                      + r->server->doc_root_len),
+                  ngx_palloc(r->pool,
+                             r->server->doc_root_len + r->uri.len
+                             + cf->max_index_len),
                   NGX_HTTP_INTERNAL_SERVER_ERROR);
 
-    loc = ngx_cpystrn(name, r->server->doc_root, r->server->doc_root_len);
-    file = ngx_cpystrn(loc, r->uri_start, r->uri_end - r->uri_start + 1);
+    loc.data = ngx_cpystrn(name, r->server->doc_root, r->server->doc_root_len);
+    file = ngx_cpystrn(loc.data, r->uri.data, r->uri.len + 1);
 
-    index = (ngx_http_index_file_t *) cf->indices->elts;
+    index = (ngx_str_t *) cf->indices->elts;
     for (i = 0; i < cf->indices->nelts; i++) {
-        ngx_memcpy(file, index[i].name, index[i].len);
+        ngx_memcpy(file, index[i].data, index[i].len + 1);
 
         fd = ngx_open_file(name, NGX_FILE_RDONLY);
         if (fd == -1) {
@@ -75,15 +82,18 @@
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
 
-        r->filename = name; 
+        r->filename.len = r->server->doc_root_len + r->uri.len + index[i].len;
+        r->filename.data = name; 
         r->fd = fd; 
 
+        loc.len = r->uri.len + index[i].len;
         return ngx_http_internal_redirect(r, loc);
     }
 
     return NGX_DECLINED;
 }
 
+
 static void *ngx_http_index_create_conf(ngx_pool_t *pool)
 {
     ngx_http_index_conf_t  *conf;
@@ -91,38 +101,42 @@
     ngx_test_null(conf, ngx_pcalloc(pool, sizeof(ngx_http_index_conf_t)), NULL);
 
     ngx_test_null(conf->indices,
-                  ngx_create_array(pool, sizeof(ngx_http_index_file_t), 3),
+                  ngx_create_array(pool, sizeof(ngx_str_t), 3),
                   NULL);
 
     return conf;
 }
 
+
 static void *ngx_http_index_merge_conf(ngx_pool_t *p, void *parent, void *child)
 {
     ngx_http_index_conf_t *prev = (ngx_http_index_conf_t *) parent;
     ngx_http_index_conf_t *conf = (ngx_http_index_conf_t *) child;
-    ngx_http_index_file_t *index;
+    ngx_str_t  *index;
 
     if (conf->max_index_len == 0) {
         if (prev->max_index_len != 0)
             return prev;
 
         ngx_test_null(index, ngx_push_array(conf->indices), NULL);
-        index->name = NGX_HTTP_INDEX;
-        conf->max_index_len = index->len = sizeof(NGX_HTTP_INDEX) + 1;
+        index->len = sizeof(NGX_HTTP_INDEX) - 1;
+        index->data = NGX_HTTP_INDEX;
+        conf->max_index_len = sizeof(NGX_HTTP_INDEX);
     }
 
     return conf;
 }
 
-static char *ngx_http_index_set_index(ngx_pool_t *p, void *conf, char *value)
+
+static char *ngx_http_index_set_index(ngx_pool_t *p, void *conf,
+                                      ngx_str_t *value)
 {
     ngx_http_index_conf_t *cf = (ngx_http_index_conf_t *) conf;
-    ngx_http_index_file_t *index;
+    ngx_str_t  *index;
 
     ngx_test_null(index, ngx_push_array(cf->indices), NULL);
-    index->name = value;
-    index->len = strlen(value) + 1;
+    index->len = value->len;
+    index->data = value->data;
 
     if (cf->max_index_len < index->len)
         cf->max_index_len = index->len;
diff --git a/src/http/modules/ngx_http_index_handler.h b/src/http/modules/ngx_http_index_handler.h
index 721bf25..66261b0 100644
--- a/src/http/modules/ngx_http_index_handler.h
+++ b/src/http/modules/ngx_http_index_handler.h
@@ -14,11 +14,6 @@
     size_t        max_index_len;
 } ngx_http_index_conf_t;
 
-typedef struct {
-    char   *name;
-    size_t  len;
-} ngx_http_index_file_t;
-
 
 extern ngx_http_module_t  ngx_http_index_module;
 
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 6b20839..cded5f0 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -40,11 +40,13 @@
     ctx = r->connection->log->data;
     ctx->action = "sending response";
 
-    r->fd = ngx_open_file(r->filename, NGX_FILE_RDONLY);
+    if (r->fd != -1)
+        r->fd = ngx_open_file(r->filename.data, NGX_FILE_RDONLY);
+
     if (r->fd == -1) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
                       "ngx_http_static_handler: "
-                      ngx_open_file_n " %s failed", r->filename);
+                      ngx_open_file_n " %s failed", r->filename.data);
 
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
@@ -52,7 +54,7 @@
     if (ngx_stat_fd(r->fd, &r->fileinfo) == -1) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
                       "ngx_http_static_handler: "
-                      ngx_stat_fd_n " %s failed", r->filename);
+                      ngx_stat_fd_n " %s failed", r->filename.data);
 
         /* close fd */
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -64,25 +66,35 @@
     r->headers_out.last_modified = ngx_file_mtime(r->fileinfo);
 */
 
+    ngx_test_null(r->headers_out.content_type,
+                  ngx_push_table(r->headers_out.headers),
+                  NGX_HTTP_INTERNAL_SERVER_ERROR);
+    r->headers_out.content_type->key.len = 12;
+    r->headers_out.content_type->key.data = "Content-Type";
+
     /* STUB */
-    if (r->exten) {
-        if (strcasecmp(r->exten, "html") == 0)
-            r->headers_out.content_type = "text/html; charset=koi8-r";
-        else if (strcasecmp(r->exten, "gif") == 0)
-            r->headers_out.content_type = "image/gif";
-        else if (strcasecmp(r->exten, "jpg") == 0)
-            r->headers_out.content_type = "image/jpeg";
-        else if (strcasecmp(r->exten, "pdf") == 0)
-            r->headers_out.content_type = "application/pdf";
+    if (r->exten.len) {
+        if (strcasecmp(r->exten.data, "html") == 0) {
+            r->headers_out.content_type->value.len = 25;
+            r->headers_out.content_type->value.data =
+                                                   "text/html; charset=koi8-r";
+        } else if (strcasecmp(r->exten.data, "gif") == 0) {
+            r->headers_out.content_type->value.len = 9;
+            r->headers_out.content_type->value.data = "image/gif";
+        } else if (strcasecmp(r->exten.data, "jpg") == 0) {
+            r->headers_out.content_type->value.len = 10;
+            r->headers_out.content_type->value.data = "image/jpeg";
+        }
 
     } else {
-        r->headers_out.content_type = "text/html; charset=koi8-r";
+        r->headers_out.content_type->value.len = 25;
+        r->headers_out.content_type->value.data = "text/html; charset=koi8-r";
     }
 
     /* STUB */
     rc = ngx_http_header_filter(r);
 /*
-    rc = ngx_send_http_header(r->headers_out);
+    rc = ngx_send_http_header(r);
 */
     if (r->header_only)
         return rc;