nginx-0.1.19-RELEASE import

    *) Bugfix: now, if request contains the zero, then the 404 error is
       returned for the local requests.

    *) Bugfix: nginx could not be built on NetBSD 2.0.

    *) Bugfix: the timeout may occur while reading of the the client
       request body via SSL connections.
diff --git a/src/http/modules/ngx_http_autoindex_handler.c b/src/http/modules/ngx_http_autoindex_handler.c
index ac2438e..2e555a0 100644
--- a/src/http/modules/ngx_http_autoindex_handler.c
+++ b/src/http/modules/ngx_http_autoindex_handler.c
@@ -128,6 +128,11 @@
         return NGX_DECLINED;
     }
 
+    /* TODO: Win32 */
+    if (r->zero_in_uri) {
+        return NGX_DECLINED;
+    }
+
     alcf = ngx_http_get_module_loc_conf(r, ngx_http_autoindex_module);
 
     if (!alcf->enable) {
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c
index 7d17f03..0d8267d 100644
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -10,9 +10,9 @@
 
 
 typedef struct {
-    ngx_radix_tree_t           *tree;
-    ngx_pool_t                 *pool;
-    ngx_array_t                 values;
+    ngx_radix_tree_t  *tree;
+    ngx_pool_t        *pool;
+    ngx_array_t        values;
 } ngx_http_geo_conf_t;
 
 
@@ -63,21 +63,31 @@
 
 /* AF_INET only */
 
-static ngx_http_variable_value_t *ngx_http_geo_variable(ngx_http_request_t *r,
-                                                        void *data)
+static ngx_http_variable_value_t *
+ngx_http_geo_variable(ngx_http_request_t *r, void *data)
 {
     ngx_radix_tree_t *tree = data;
 
-    struct sockaddr_in  *sin;
+    struct sockaddr_in         *sin;
+    ngx_http_variable_value_t  *var;
 
     sin = (struct sockaddr_in *) r->connection->sockaddr;
 
-    return (ngx_http_variable_value_t *)
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "http geo started");
+
+    var  = (ngx_http_variable_value_t *)
                        ngx_radix32tree_find(tree, ntohl(sin->sin_addr.s_addr));
+
+    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "http geo: %V %V", &r->connection->addr_text, &var->text);
+
+    return var;
 }
 
 
-static char *ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+static char *
+ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
     char                 *rv;
     ngx_str_t            *value;
@@ -91,7 +101,7 @@
         return NGX_CONF_ERROR;
     }
 
-    if (!(tree = ngx_radix_tree_create(cf->pool, 8))) {
+    if (!(tree = ngx_radix_tree_create(cf->pool, -1))) {
         return NGX_CONF_ERROR;
     }
 
@@ -148,7 +158,8 @@
 
 /* AF_INET only */
 
-static char *ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
+static char *
+ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
 {
     ngx_int_t                   rc, n;
     ngx_uint_t                  i;
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index ccf5dc4..c7a16a7 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -216,7 +216,7 @@
     NULL,                                  /* merge server configuration */
 
     ngx_http_gzip_create_conf,             /* create location configuration */
-    ngx_http_gzip_merge_conf,              /* merge location configuration */
+    ngx_http_gzip_merge_conf               /* merge location configuration */
 };
 
 
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 892b825..1c7d0df 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -120,6 +120,11 @@
         return NGX_DECLINED;
     }
 
+    /* TODO: Win32 */
+    if (r->zero_in_uri) {
+        return NGX_DECLINED;
+    }
+
     log = r->connection->log;
 
     /*
diff --git a/src/http/modules/ngx_http_ssi_filter.c b/src/http/modules/ngx_http_ssi_filter.c
index 334dd53..eeb515f 100644
--- a/src/http/modules/ngx_http_ssi_filter.c
+++ b/src/http/modules/ngx_http_ssi_filter.c
@@ -518,48 +518,49 @@
 #endif
 
 
-static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r,
-                                    ngx_http_ssi_ctx_t *ctx)
+static ngx_int_t
+ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx)
 {
-    char                  *p, *last, *end, ch;
+    u_char                *p, *last, *end, ch;
     ngx_http_ssi_conf_t   *conf;
     ngx_http_ssi_state_e   state;
 
     conf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module);
 
     state = ctx->state;
-    p = ctx->pos;
     end = ctx->buf->last;
     last = NULL;
 
-    while (p < end) {
-        ch = *p++;
+    for (p = ctx->pos; p < end; p++) {
+
+        ch = *p;
+
+        if (state == ssi_start_state) {
+
+            /* the tight loop */
+
+            for ( /* void */ ; p < end; p++) {
+                if (ch != '<') {
+                    continue;
+                }
+
+                last = p;
+                state = ssi_tag_state;
+                break;
+            }
+
+            if (p == end) {
+                ctx->last = p;
+                ctx->pos = p;
+                ctx->state = ssi_start_state;
+
+                return NGX_HTTP_SSI_COPY;
+            }
+        }
 
         switch (state) {
 
         case ssi_start_state:
-
-            /* a tight loop */
-
-            for ( ;; ) {
-
-                if (ch == '<') {
-                    last = p - 1;
-                    state = ssi_tag_state;
-                    break;
-                }
-
-                if (p == end) {
-                    ctx->last = p;
-                    ctx->pos = p;
-                    ctx->state = ssi_start_state;
-
-                    return NGX_HTTP_SSI_COPY;
-                }
-
-                ch = *p++;
-            }
-
             break;
 
         case ssi_tag_state:
@@ -569,7 +570,7 @@
                 break;
 
             case '<':
-                last = p - 1;
+                last = p;
                 break;
 
             default:
@@ -586,7 +587,7 @@
                 break;
 
             case '<':
-                last = p - 1;
+                last = p;
                 state = ssi_tag_state;
                 break;
 
@@ -604,7 +605,7 @@
                 break;
 
             case '<':
-                last = p - 1;
+                last = p;
                 state = ssi_tag_state;
                 break;
 
@@ -621,11 +622,10 @@
                 ctx->last = last;
                 ctx->pos = p;
                 ctx->state = ssi_precommand_state;
-
-                return NGX_HTTP_SSI_COPY;
+                break;
 
             case '<':
-                last = p - 1;
+                last = p;
                 state = ssi_tag_state;
                 break;
 
@@ -645,14 +645,14 @@
                 break;
 
             default:
+                ctx->command.len = 1;
                 ctx->command.data = 
-                             ngx_palloc(r->pool, NGX_HTTP_SSI_COMMAND_LEN + 1);
+                                 ngx_palloc(r->pool, NGX_HTTP_SSI_COMMAND_LEN);
                 if (ctx->command.data == NULL) {
                     return NGX_ERROR;
                 }
 
                 ctx->command.data[0] = ch;
-                ctx->command.len = 1;
                 state = ssi_command_state;
                 break;
             }
@@ -665,20 +665,15 @@
             case CR:
             case LF:
             case '\t':
-                ctx->command.data[ctx->command.len] = 0;
                 state = ssi_preparam_state;
                 break;
 
             case '-':
-                ctx->command.data[ctx->command.len] = 0;
                 state = ssi_comment_end0_state;
                 break;
 
             default:
-                if (ctx->command.len >= NGX_HTTP_SSI_COMMAND_LEN) {
-                    ctx->command.data[NGX_HTTP_SSI_COMMAND_LEN] = 0;
-
-                    ctx->last = last;
+                if (ctx->command.len == NGX_HTTP_SSI_COMMAND_LEN) {
                     ctx->pos = p;
                     ctx->state = ssi_error_state;
 
@@ -704,28 +699,30 @@
 
             default:
                 if (ctx->params.elts == NULL) {
-                    ngx_init_array(ctx->params, r->pool,
-                                   5, sizeof(ngx_table_elt_t), NGX_ERROR);
+                    if (ngx_array_init(&ctx->params = r->pool,
+                                       4, sizeof(ngx_table_elt_t)) = NGX_ERROR)
+                    {
+                        return NGX_ERROR;
+                    }
                 }
 
-                if (!(ctx->param = ngx_push_array(&ctx->params))) {
+                if (!(ctx->param = ngx_array_push(&ctx->params))) {
                     return NGX_ERROR;
                 }
 
+                ctx->param->key.len = 1;
                 ctx->param->key.data =
-                               ngx_palloc(r->pool, NGX_HTTP_SSI_PARAM_LEN + 1);
+                                   ngx_palloc(r->pool, NGX_HTTP_SSI_PARAM_LEN);
                 if (ctx->param->key.data == NULL) {
                     return NGX_ERROR;
                 }
                 ctx->param->key.data[0] = ch;
-                ctx->param->key.len = 1;
 
-                ctx->param->value.data =
-                                       ngx_palloc(r->pool, conf->value_len + 1);
+                ctx->param->value.len = 0;
+                ctx->param->value.data = ngx_palloc(r->pool, conf->value_len);
                 if (ctx->param->value.data == NULL) {
                     return NGX_ERROR;
                 }
-                ctx->param->value.len = 0;
 
                 state = ssi_param_state;
                 break;
@@ -739,27 +736,21 @@
             case CR:
             case LF:
             case '\t':
-                ctx->param->key.data[ctx->param->key.len] = 0;
                 state = ssi_preequal_state;
                 break;
 
             case '=':
-                ctx->param->key.data[ctx->param->key.len] = 0;
                 state = ssi_prevalue_state;
                 break;
 
             case '-':
-                ctx->last = last;
                 ctx->pos = p;
                 ctx->state = ssi_error_end0_state;
 
                 return NGX_HTTP_SSI_INVALID_PARAM;
 
             default:
-                if (ctx->param->key.len >= NGX_HTTP_SSI_PARAM_LEN) {
-                    ctx->param->key.data[NGX_HTTP_SSI_PARAM_LEN] = 0;
-
-                    ctx->last = last;
+                if (ctx->param->key.len == NGX_HTTP_SSI_PARAM_LEN) {
                     ctx->pos = p;
                     ctx->state = ssi_error_state;
 
@@ -784,7 +775,6 @@
                 break;
 
             case '-':
-                ctx->last = last;
                 ctx->pos = p;
                 ctx->state = ssi_error_end0_state;
 
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index fa2bcd5..1ff45da 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -87,6 +87,11 @@
         return NGX_DECLINED;
     }
 
+    /* TODO: Win32 */
+    if (r->zero_in_uri) {
+        return NGX_DECLINED;
+    }
+
     if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
         return NGX_HTTP_NOT_ALLOWED;
     }
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 8b66a79..b3c1a14 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -415,6 +415,8 @@
 
     r->uri_changed = 1;
     r->uri_changes = 11;
+    r->phase = NGX_HTTP_REWRITE_PHASE;
+    r->phase_handler = 0;
 
     ngx_http_core_run_phases(r);
 }
@@ -447,11 +449,7 @@
 
     for (/* void */; r->phase < NGX_HTTP_LAST_PHASE; r->phase++) {
 
-        if (r->phase == NGX_HTTP_FIND_CONFIG_PHASE && !r->uri_changed) {
-            continue;
-        }
-
-        if (r->phase == NGX_HTTP_FIND_CONFIG_PHASE + 1 && r->uri_changed) {
+        if (r->phase == NGX_HTTP_REWRITE_PHASE + 1 && r->uri_changed) {
 
             ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                            "uri changes: %d", r->uri_changes);
@@ -472,8 +470,7 @@
                 return;
             }
 
-            r->uri_changed = 0;
-            r->phase = NGX_HTTP_REWRITE_PHASE;
+            r->phase = NGX_HTTP_FIND_CONFIG_PHASE;
         }
 
         if (r->phase == NGX_HTTP_CONTENT_PHASE && r->content_handler) {
@@ -525,7 +522,7 @@
 
     /* no content handler was found */
 
-    if (r->uri.data[r->uri.len - 1] == '/') {
+    if (r->uri.data[r->uri.len - 1] == '/' && !r->zero_in_uri) {
 
         clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
@@ -550,6 +547,9 @@
     ngx_http_core_loc_conf_t  *clcf;
     ngx_http_core_srv_conf_t  *cscf;
 
+    r->content_handler = NULL;
+    r->uri_changed = 0;
+
     cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
 
     rc = ngx_http_core_find_location(r, &cscf->locations, 0);
@@ -955,10 +955,6 @@
     cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
     r->loc_conf = cscf->ctx->loc_conf;
 
-    r->phase = 0;
-    r->phase_handler = 0;
-    r->content_handler = NULL;
-
     ngx_http_handler(r);
 
     return NGX_DONE;
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 1c60991..dbaef6f 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -25,9 +25,9 @@
 
 
 typedef enum {
-    NGX_HTTP_REWRITE_PHASE = 0,
+    NGX_HTTP_FIND_CONFIG_PHASE = 0,
 
-    NGX_HTTP_FIND_CONFIG_PHASE,
+    NGX_HTTP_REWRITE_PHASE,
 
     NGX_HTTP_ACCESS_PHASE,
     NGX_HTTP_CONTENT_PHASE,
diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c
index 722b9f8..0d031fe 100644
--- a/src/http/ngx_http_log_handler.c
+++ b/src/http/ngx_http_log_handler.c
@@ -137,7 +137,7 @@
     { ngx_string("addr"), INET_ADDRSTRLEN - 1, NULL, NULL, ngx_http_log_addr },
     { ngx_string("conn"), NGX_INT32_LEN, NULL, NULL, ngx_http_log_connection },
     { ngx_string("pipe"), 1, NULL, NULL, ngx_http_log_pipe },
-    { ngx_string("time"), sizeof("28/Sep/1970:12:00:00") - 1,
+    { ngx_string("time"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
                           NULL, NULL, ngx_http_log_time },
     { ngx_string("msec"), NGX_TIME_T_LEN + 4, NULL, NULL, ngx_http_log_msec },
     { ngx_string("status"), 3, NULL, NULL, ngx_http_log_status },
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index f5912ac..ca84d16 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -109,6 +109,12 @@
 
         /* space* before URI */
         case sw_spaces_before_uri:
+            if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
+                r->schema_start = p;
+                state = sw_schema;
+                break;
+            }
+
             switch (ch) {
             case '/':
                 r->uri_start = p;
@@ -117,25 +123,21 @@
             case ' ':
                 break;
             default:
-                if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
-                    r->schema_start = p;
-                    state = sw_schema;
-                    break;
-                }
                 return NGX_HTTP_PARSE_INVALID_REQUEST;
             }
             break;
 
         case sw_schema:
+            if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
+                break;
+            }
+
             switch (ch) {
             case ':':
                 r->schema_end = p;
                 state = sw_schema_slash;
                 break;
             default:
-                if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
-                    break;
-                }
                 return NGX_HTTP_PARSE_INVALID_REQUEST;
             }
             break;
@@ -162,6 +164,12 @@
             break;
 
         case sw_host:
+            if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')
+                || (ch >= '0' && ch <= '9') || ch == '.' || ch == '-')
+            {
+                break;
+            }
+
             switch (ch) {
             case ':':
                 r->host_end = p;
@@ -173,16 +181,15 @@
                 state = sw_after_slash_in_uri;
                 break;
             default:
-                if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')
-                    || (ch >= '0' && ch <= '9') || ch == '.' || ch == '-')
-                {
-                    break;
-                }
                 return NGX_HTTP_PARSE_INVALID_REQUEST;
             }
             break;
 
         case sw_port:
+            if (ch >= '0' && ch <= '9') {
+                break;
+            }
+
             switch (ch) {
             case '/':
                 r->port_end = p;
@@ -190,16 +197,26 @@
                 state = sw_after_slash_in_uri;
                 break;
             default:
-                if (ch < '0' && ch > '9') {
-                    return NGX_HTTP_PARSE_INVALID_REQUEST;
-                }
-                break;
+                return NGX_HTTP_PARSE_INVALID_REQUEST;
             }
             break;
 
         /* check "/.", "//", "%", and "\" (Win32) in URI */
         case sw_after_slash_in_uri:
+
+            if ((ch >= 'a' && ch <= 'z')
+                || (ch >= 'A' && ch <= 'Z')
+                || (ch >= '0' && ch <= '9'))
+            {
+                state = sw_check_uri;
+                break;
+            }
+
             switch (ch) {
+            case ' ':
+                r->uri_end = p;
+                state = sw_http_09;
+                break;
             case CR:
                 r->uri_end = p;
                 r->http_minor = 9;
@@ -209,10 +226,6 @@
                 r->uri_end = p;
                 r->http_minor = 9;
                 goto done;
-            case ' ':
-                r->uri_end = p;
-                state = sw_http_09;
-                break;
             case '.':
                 r->complex_uri = 1;
                 state = sw_uri;
@@ -221,20 +234,25 @@
                 r->quoted_uri = 1;
                 state = sw_uri;
                 break;
+            case '/':
+                r->complex_uri = 1;
+                state = sw_uri;
+                break;
 #if (NGX_WIN32)
             case '\\':
                 r->complex_uri = 1;
+                state = sw_uri;
                 break;
 #endif
-            case '/':
-                r->complex_uri = 1;
+            case '?':
+                r->args_start = p + 1;
+                state = sw_uri;
                 break;
             case '+':
                 r->plus_in_uri = 1;
                 break;
-            case '?':
-                r->args_start = p + 1;
-                state = sw_uri;
+            case '\0':
+                r->zero_in_uri = 1;
                 break;
             default:
                 state = sw_check_uri;
@@ -244,7 +262,26 @@
 
         /* check "/", "%" and "\" (Win32) in URI */
         case sw_check_uri:
+
+            if ((ch >= 'a' && ch <= 'z')
+                || (ch >= 'A' && ch <= 'Z')
+                || (ch >= '0' && ch <= '9'))
+            {
+                break;
+            }
+
             switch (ch) {
+            case '/':
+                r->uri_ext = NULL;
+                state = sw_after_slash_in_uri;
+                break;
+            case '.':
+                r->uri_ext = p + 1;
+                break;
+            case ' ':
+                r->uri_end = p;
+                state = sw_http_09;
+                break;
             case CR:
                 r->uri_end = p;
                 r->http_minor = 9;
@@ -254,40 +291,36 @@
                 r->uri_end = p;
                 r->http_minor = 9;
                 goto done;
-            case ' ':
-                r->uri_end = p;
-                state = sw_http_09;
-                break;
-            case '.':
-                r->uri_ext = p + 1;
-                break;
 #if (NGX_WIN32)
             case '\\':
                 r->complex_uri = 1;
                 state = sw_after_slash_in_uri;
                 break;
 #endif
-            case '/':
-                r->uri_ext = NULL;
-                state = sw_after_slash_in_uri;
-                break;
-            case '+':
-                r->plus_in_uri = 1;
-                break;
             case '%':
                 r->quoted_uri = 1;
                 state = sw_uri;
                 break;
+            case '+':
+                r->plus_in_uri = 1;
+                break;
             case '?':
                 r->args_start = p + 1;
                 state = sw_uri;
                 break;
+            case '\0':
+                r->zero_in_uri = 1;
+                break;
             }
             break;
 
         /* URI */
         case sw_uri:
             switch (ch) {
+            case ' ':
+                r->uri_end = p;
+                state = sw_http_09;
+                break;
             case CR:
                 r->uri_end = p;
                 r->http_minor = 9;
@@ -300,9 +333,8 @@
             case '+':
                 r->plus_in_uri = 1;
                 break;
-            case ' ':
-                r->uri_end = p;
-                state = sw_http_09;
+            case '\0':
+                r->zero_in_uri = 1;
                 break;
             }
             break;
@@ -946,12 +978,20 @@
         case sw_quoted_second:
             if (ch >= '0' && ch <= '9') {
                 ch = (u_char) ((decoded << 4) + ch - '0');
+
                 if (ch == '%') {
                     state = sw_usual;
                     *u++ = ch;
                     ch = *p++;
                     break;
                 }
+
+                if (ch == '\0') {
+                    r->zero_in_uri = 1;
+                    *u++ = ch;
+                    ch = *p++;
+                }
+
                 state = quoted_state;
                 break;
             }
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 209c547..a6046f1 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -58,13 +58,13 @@
     { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host) },
     { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection) },
     { ngx_string("If-Modified-Since"),
-                         offsetof(ngx_http_headers_in_t, if_modified_since) },
+                 offsetof(ngx_http_headers_in_t, if_modified_since) },
     { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) },
     { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer) },
     { ngx_string("Content-Length"),
-                            offsetof(ngx_http_headers_in_t, content_length) },
+                 offsetof(ngx_http_headers_in_t, content_length) },
     { ngx_string("Content-Type"),
-                              offsetof(ngx_http_headers_in_t, content_type) },
+                 offsetof(ngx_http_headers_in_t, content_type) },
 
     { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range) },
 #if 0
@@ -73,22 +73,29 @@
 
 #if (NGX_HTTP_GZIP)
     { ngx_string("Accept-Encoding"),
-                           offsetof(ngx_http_headers_in_t, accept_encoding) },
+                 offsetof(ngx_http_headers_in_t, accept_encoding) },
     { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via) },
 #endif
 
     { ngx_string("Authorization"),
-                             offsetof(ngx_http_headers_in_t, authorization) },
+                 offsetof(ngx_http_headers_in_t, authorization) },
 
     { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive) },
 
 #if (NGX_HTTP_PROXY)
     { ngx_string("X-Forwarded-For"),
-                           offsetof(ngx_http_headers_in_t, x_forwarded_for) },
+                 offsetof(ngx_http_headers_in_t, x_forwarded_for) },
     { ngx_string("X-Real-IP"), offsetof(ngx_http_headers_in_t, x_real_ip) },
     { ngx_string("X-URL"), offsetof(ngx_http_headers_in_t, x_url) },
 #endif
 
+#if (NGX_HTTP_HEADERS)
+    { ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept) },
+    { ngx_string("Accept-Language"),
+                 offsetof(ngx_http_headers_in_t, accept_language) },
+    { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via) },
+#endif
+
     { ngx_null_string, 0 }
 };
 
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index a4e3d0e..542a689 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -152,6 +152,11 @@
     ngx_table_elt_t  *x_url;
 #endif
 
+#if (NGX_HTTP_HEADERS)
+    ngx_table_elt_t  *accept;
+    ngx_table_elt_t  *accept_language;
+#endif
+
     ngx_array_t       cookies;
 
     size_t            host_name_len;
@@ -325,6 +330,9 @@
     /* URI with "+" */
     unsigned             plus_in_uri:1;
 
+    /* URI with "\0" or "%00" */
+    unsigned             zero_in_uri:1;
+
     unsigned             uri_changed:1;
     unsigned             uri_changes:4;
 
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index d4de4a1..759801f 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -94,6 +94,7 @@
                           cl->buf->file_last);
 
             ngx_debug_point();
+            return NGX_ERROR;
         }
 #endif
 
@@ -144,6 +145,7 @@
                           cl->buf->file_last);
 
             ngx_debug_point();
+            return NGX_ERROR;
         }
 #endif