nginx-0.0.7-2004-06-16-19:32:11 import
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index b79a460..63ac0e1 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -128,7 +128,7 @@
 static ngx_http_output_body_filter_pt    ngx_http_next_body_filter;
 
 
-static int ngx_http_charset_header_filter(ngx_http_request_t *r)
+static ngx_int_t ngx_http_charset_header_filter(ngx_http_request_t *r)
 {
     ngx_http_charset_t            *charsets;
     ngx_http_charset_ctx_t        *ctx;
@@ -190,7 +190,8 @@
 }
 
 
-static int ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
+static ngx_int_t ngx_http_charset_body_filter(ngx_http_request_t *r,
+                                              ngx_chain_t *in)
 {
     char                          *table;
     ngx_chain_t                   *cl;
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c
index c429fa8..bd4c270 100644
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -4,7 +4,7 @@
 #include <ngx_http.h>
 
 
-static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_chunked_filter_init(ngx_cycle_t *cycle);
 
 
 static ngx_http_module_t  ngx_http_chunked_filter_module_ctx = {
@@ -35,7 +35,7 @@
 static ngx_http_output_body_filter_pt    ngx_http_next_body_filter;
 
 
-static int ngx_http_chunked_header_filter(ngx_http_request_t *r)
+static ngx_int_t ngx_http_chunked_header_filter(ngx_http_request_t *r)
 {
     if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) {
         return ngx_http_next_header_filter(r);
@@ -54,7 +54,8 @@
 }
 
 
-static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
+static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
+                                              ngx_chain_t *in)
 {
     u_char       *chunk;
     size_t        size, len;
@@ -138,7 +139,7 @@
 }
 
 
-static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_chunked_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_next_header_filter = ngx_http_top_header_filter;
     ngx_http_top_header_filter = ngx_http_chunked_header_filter;
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index 0e02015..5f3825e 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -64,8 +64,8 @@
 } ngx_http_gzip_ctx_t;
 
 
-static int ngx_http_gzip_proxied(ngx_http_request_t *r,
-                                 ngx_http_gzip_conf_t *conf);
+static ngx_int_t ngx_http_gzip_proxied(ngx_http_request_t *r,
+                                       ngx_http_gzip_conf_t *conf);
 static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items,
                                         u_int size);
 static void ngx_http_gzip_filter_free(void *opaque, void *address);
@@ -74,8 +74,8 @@
 static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf,
                                        uintptr_t data);
 
-static int ngx_http_gzip_pre_conf(ngx_conf_t *cf);
-static int ngx_http_gzip_filter_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_gzip_pre_conf(ngx_conf_t *cf);
+static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle);
 static void *ngx_http_gzip_create_conf(ngx_conf_t *cf);
 static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf,
                                       void *parent, void *child);
@@ -238,7 +238,7 @@
 static ngx_http_output_body_filter_pt    ngx_http_next_body_filter;
 
 
-static int ngx_http_gzip_header_filter(ngx_http_request_t *r)
+static ngx_int_t ngx_http_gzip_header_filter(ngx_http_request_t *r)
 {
     ngx_http_gzip_ctx_t   *ctx;
     ngx_http_gzip_conf_t  *conf;
@@ -288,10 +288,7 @@
      * hangs up or crashes
      */
 
-    if (r->headers_in.user_agent
-        && r->unparsed_uri.len > 200
-        && ngx_strstr(r->headers_in.user_agent->value.data, "MSIE 4"))
-    {
+    if (r->headers_in.msie4 && r->unparsed_uri.len > 200) {
         return ngx_http_next_header_filter(r);
     }
 
@@ -323,8 +320,8 @@
 }
 
 
-static int ngx_http_gzip_proxied(ngx_http_request_t *r,
-                                 ngx_http_gzip_conf_t *conf)
+static ngx_int_t ngx_http_gzip_proxied(ngx_http_request_t *r,
+                                       ngx_http_gzip_conf_t *conf)
 {
     time_t  date, expires;
 
@@ -403,7 +400,8 @@
 }
 
 
-static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
+static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r,
+                                           ngx_chain_t *in)
 {
     int                    rc, wbits, memlevel, last;
     struct gztrailer      *trailer;
@@ -819,7 +817,8 @@
     }
 
     return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4,
-                              "%d.%02d", zint, zfrac);
+                              "%" NGX_UINT_T_FMT ".%02" NGX_UINT_T_FMT,
+                              zint, zfrac);
 }
 
 
@@ -838,7 +837,7 @@
 }
 
 
-static int ngx_http_gzip_pre_conf(ngx_conf_t *cf)
+static ngx_int_t ngx_http_gzip_pre_conf(ngx_conf_t *cf)
 {
     ngx_http_log_op_name_t  *op;
 
@@ -859,7 +858,7 @@
 }
 
 
-static int ngx_http_gzip_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_next_header_filter = ngx_http_top_header_filter;
     ngx_http_top_header_filter = ngx_http_gzip_header_filter;
@@ -894,9 +893,9 @@
     conf->http_version = NGX_CONF_UNSET_UINT;
 
     conf->level = NGX_CONF_UNSET;
-    conf->wbits = NGX_CONF_UNSET_UINT;
-    conf->memlevel = NGX_CONF_UNSET_UINT;
-    conf->min_length = NGX_CONF_UNSET_UINT;
+    conf->wbits = (size_t) NGX_CONF_UNSET;
+    conf->memlevel = (size_t) NGX_CONF_UNSET;
+    conf->min_length = NGX_CONF_UNSET;
 
     return conf;
 }
diff --git a/src/http/modules/ngx_http_headers_filter.c b/src/http/modules/ngx_http_headers_filter.c
index 560b5b1..7f74b47 100644
--- a/src/http/modules/ngx_http_headers_filter.c
+++ b/src/http/modules/ngx_http_headers_filter.c
@@ -14,7 +14,7 @@
 #define NGX_HTTP_EXPIRES_EPOCH   -2147483645
 
 
-static int ngx_http_headers_filter_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle);
 static void *ngx_http_headers_create_conf(ngx_conf_t *cf);
 static char *ngx_http_headers_merge_conf(ngx_conf_t *cf,
                                          void *parent, void *child);
@@ -61,7 +61,7 @@
 static ngx_http_output_header_filter_pt  ngx_http_next_header_filter;
 
 
-static int ngx_http_headers_filter(ngx_http_request_t *r)
+static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r)
 {
     size_t                    len;
     ngx_table_elt_t          *expires, *cc;
@@ -145,7 +145,7 @@
 }
 
 
-static int ngx_http_headers_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_next_header_filter = ngx_http_top_header_filter;
     ngx_http_top_header_filter = ngx_http_headers_filter;
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index de609ac..80e4d19 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -29,7 +29,7 @@
 static ngx_int_t ngx_http_index_error(ngx_http_request_t *r,
                                       ngx_http_index_ctx_t *ctx, ngx_err_t err);
 
-static int ngx_http_index_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle);
 static void *ngx_http_index_create_loc_conf(ngx_conf_t *cf);
 static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf,
                                        void *parent, void *child);
@@ -95,7 +95,7 @@
  * that path contains the usual file in place of the directory.
  */
 
-int ngx_http_index_handler(ngx_http_request_t *r)
+ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
 {
     u_char                     *name;
     ngx_fd_t                    fd;
@@ -361,7 +361,7 @@
 }
 
 
-static int ngx_http_index_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle)
 {
     ngx_http_handler_pt        *h;
     ngx_http_conf_ctx_t        *ctx;
diff --git a/src/http/modules/ngx_http_not_modified_filter.c b/src/http/modules/ngx_http_not_modified_filter.c
index e1a961f..f14a78b 100644
--- a/src/http/modules/ngx_http_not_modified_filter.c
+++ b/src/http/modules/ngx_http_not_modified_filter.c
@@ -5,7 +5,7 @@
 
 
 
-static int ngx_http_not_modified_filter_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_not_modified_filter_init(ngx_cycle_t *cycle);
 
 
 static ngx_http_module_t  ngx_http_not_modified_filter_module_ctx = {
@@ -35,7 +35,7 @@
 static ngx_http_output_header_filter_pt  ngx_http_next_header_filter;
 
 
-static int ngx_http_not_modified_header_filter(ngx_http_request_t *r)
+static ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
 {
     time_t  ims;
 
@@ -71,7 +71,7 @@
 }
 
 
-static int ngx_http_not_modified_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_not_modified_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_next_header_filter = ngx_http_top_header_filter;
     ngx_http_top_header_filter = ngx_http_not_modified_header_filter;
diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c
index 65a5fd0..8d3e3dd 100644
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -339,7 +339,7 @@
             if (r->headers_out.charset.len) {
                 ctx->boundary_header.len =
                          ngx_snprintf((char *) ctx->boundary_header.data, len,
-                                      CRLF "--%010u" CRLF
+                                      CRLF "--%010" NGX_UINT_T_FMT CRLF
                                       "Content-Type: %s; charset=%s" CRLF
                                       "Content-Range: bytes ",
                                       boundary,
@@ -351,7 +351,7 @@
             } else {
                 ctx->boundary_header.len =
                          ngx_snprintf((char *) ctx->boundary_header.data, len,
-                                      CRLF "--%010u" CRLF
+                                      CRLF "--%010" NGX_UINT_T_FMT CRLF
                                       "Content-Type: %s" CRLF
                                       "Content-Range: bytes ",
                                       boundary,
@@ -368,7 +368,8 @@
                       ngx_snprintf((char *)
                                    r->headers_out.content_type->value.data,
                                    31 + 10 + 1,
-                                   "multipart/byteranges; boundary=%010u",
+                                   "multipart/byteranges; boundary=%010"
+                                   NGX_UINT_T_FMT,
                                    boundary);
 
             /* the size of the last boundary CRLF "--0123456789--" CRLF */
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index d523fc1..99ac1aa 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -5,7 +5,7 @@
 #include <ngx_http_proxy_handler.h>
 
 
-static int ngx_http_proxy_handler(ngx_http_request_t *r);
+static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r);
 
 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r,
                                               u_char *buf, uintptr_t data);
@@ -14,7 +14,7 @@
 static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf,
                                          uintptr_t data);
 
-static int ngx_http_proxy_pre_conf(ngx_conf_t *cf);
+static ngx_int_t ngx_http_proxy_pre_conf(ngx_conf_t *cf);
 static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf);
 static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
                                            void *parent, void *child);
@@ -307,7 +307,7 @@
 };
 
 
-static int ngx_http_proxy_handler(ngx_http_request_t *r)
+static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r)
 {
     ngx_http_proxy_ctx_t  *p;
 
@@ -732,7 +732,8 @@
         *buf++ = '-';
 
     } else {
-        buf += ngx_snprintf((char *) buf, 4, "%d", p->state->status);
+        buf += ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT,
+                            p->state->status);
     }
 
     *buf++ = '/';
@@ -796,7 +797,7 @@
 }
 
 
-static int ngx_http_proxy_pre_conf(ngx_conf_t *cf)
+static ngx_int_t ngx_http_proxy_pre_conf(ngx_conf_t *cf)
 {
     ngx_http_log_op_name_t  *op;
 
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 73333df..9e040d6 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -14,8 +14,8 @@
 uint64_t    ngx_http_total_sent;
 
 
-int  (*ngx_http_top_header_filter) (ngx_http_request_t *r);
-int  (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
+ngx_int_t  (*ngx_http_top_header_filter) (ngx_http_request_t *r);
+ngx_int_t  (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
 
 
 static ngx_command_t  ngx_http_commands[] = {
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index 87eabd1..33d6f34 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -59,26 +59,26 @@
 
 void ngx_http_init_connection(ngx_connection_t *c);
 
-int ngx_http_parse_request_line(ngx_http_request_t *r);
-int ngx_http_parse_complex_uri(ngx_http_request_t *r);
-int ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
+ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r);
+ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r);
+ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
 
-int ngx_http_find_server_conf(ngx_http_request_t *r);
+ngx_int_t ngx_http_find_server_conf(ngx_http_request_t *r);
 void ngx_http_handler(ngx_http_request_t *r);
 void ngx_http_finalize_request(ngx_http_request_t *r, int error);
 void ngx_http_writer(ngx_event_t *wev);
 
 void ngx_http_empty_handler(ngx_event_t *wev);
 
-int ngx_http_send_last(ngx_http_request_t *r);
+ngx_int_t ngx_http_send_last(ngx_http_request_t *r);
 void ngx_http_close_request(ngx_http_request_t *r, int error);
 void ngx_http_close_connection(ngx_connection_t *c);
 
 
 ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r);
 
-int ngx_http_send_header(ngx_http_request_t *r);
-int ngx_http_special_response_handler(ngx_http_request_t *r, int error);
+ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
+ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r, int error);
 
 
 time_t ngx_http_parse_time(u_char *value, size_t len);
@@ -88,8 +88,7 @@
 
 
 
-int ngx_http_discard_body(ngx_http_request_t *r);
-
+ngx_int_t ngx_http_discard_body(ngx_http_request_t *r);
 
 
 extern ngx_module_t  ngx_http_module;
@@ -99,9 +98,12 @@
 extern uint64_t    ngx_http_total_sent;
 
 
+extern ngx_http_output_header_filter_pt  ngx_http_top_header_filter;
+extern ngx_http_output_body_filter_pt    ngx_http_top_body_filter;
+
 
 /* STUB */
-int ngx_http_log_handler(ngx_http_request_t *r);
+ngx_int_t ngx_http_log_handler(ngx_http_request_t *r);
 /**/
 
 
diff --git a/src/http/ngx_http_config.h b/src/http/ngx_http_config.h
index 45c2b7e..03c6347 100644
--- a/src/http/ngx_http_config.h
+++ b/src/http/ngx_http_config.h
@@ -14,22 +14,16 @@
 
 
 typedef struct {
-    int    (*output_header_filter) (ngx_http_request_t *r);
-    int    (*output_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
-} ngx_http_conf_filter_t;
+    ngx_int_t   (*pre_conf)(ngx_conf_t *cf);
 
+    void       *(*create_main_conf)(ngx_conf_t *cf);
+    char       *(*init_main_conf)(ngx_conf_t *cf, void *conf);
 
-typedef struct {
-    int    (*pre_conf)(ngx_conf_t *cf);
+    void       *(*create_srv_conf)(ngx_conf_t *cf);
+    char       *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf);
 
-    void  *(*create_main_conf)(ngx_conf_t *cf);
-    char  *(*init_main_conf)(ngx_conf_t *cf, void *conf);
-
-    void  *(*create_srv_conf)(ngx_conf_t *cf);
-    char  *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf);
-
-    void  *(*create_loc_conf)(ngx_conf_t *cf);
-    char  *(*merge_loc_conf)(ngx_conf_t *cf, void *prev, void *conf);
+    void       *(*create_loc_conf)(ngx_conf_t *cf);
+    char       *(*merge_loc_conf)(ngx_conf_t *cf, void *prev, void *conf);
 } ngx_http_module_t;
 
 
@@ -53,7 +47,5 @@
             ((ngx_http_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index]
 
 
-extern int (*ngx_http_top_header_filter) (ngx_http_request_t *r);
-
 
 #endif /* _NGX_HTTP_CONFIG_H_INCLUDED_ */
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index f68a605..5e43d5d 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -18,7 +18,7 @@
 static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
                                           void *parent, void *child);
 
-static int ngx_http_core_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_core_init(ngx_cycle_t *cycle);
 static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy);
 static int ngx_cmp_locations(const void *first, const void *second);
 static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -448,7 +448,7 @@
 }
 
 
-int ngx_http_find_location_config(ngx_http_request_t *r)
+ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r)
 {
     int                           rc;
     ngx_uint_t                    i;
@@ -665,7 +665,7 @@
 }
 
 
-int ngx_http_send_header(ngx_http_request_t *r)
+ngx_int_t ngx_http_send_header(ngx_http_request_t *r)
 {
     if (r->main) {
         return NGX_OK;
@@ -743,8 +743,8 @@
 }
 
 
-int ngx_http_internal_redirect(ngx_http_request_t *r,
-                               ngx_str_t *uri, ngx_str_t *args)
+ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
+                                     ngx_str_t *uri, ngx_str_t *args)
 {
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "internal redirect: \"%s\"", uri->data);
@@ -808,7 +808,7 @@
 #endif
 
 
-static int ngx_http_core_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_core_init(ngx_cycle_t *cycle)
 {
 #if 0
     ngx_http_handler_pt        *h;
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 9224e95..d0539e0 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -117,7 +117,7 @@
     ngx_str_t     name;          /* location name */
     void        **loc_conf ;     /* pointer to the modules' loc_conf */
 
-    int         (*handler) (ngx_http_request_t *r);
+    ngx_http_handler_pt  handler;
 
     ngx_str_t     root;                    /* root, alias */
 
@@ -163,27 +163,23 @@
 
 
 
-int ngx_http_find_location_config(ngx_http_request_t *r);
-int ngx_http_core_translate_handler(ngx_http_request_t *r);
+ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r);
+ngx_int_t ngx_http_core_translate_handler(ngx_http_request_t *r);
 
 ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
 ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
 
-int ngx_http_internal_redirect(ngx_http_request_t *r,
-                               ngx_str_t *uri, ngx_str_t *args);
+ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
+                                     ngx_str_t *uri, ngx_str_t *args);
 
 
-typedef int (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
-typedef int (*ngx_http_output_body_filter_pt)
+typedef ngx_int_t (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
+typedef ngx_int_t (*ngx_http_output_body_filter_pt)
                                    (ngx_http_request_t *r, ngx_chain_t *chain);
 
 
-int ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
-int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
-
-
-extern ngx_http_output_header_filter_pt  ngx_http_top_header_filter;
-extern ngx_http_output_body_filter_pt    ngx_http_top_body_filter;
+ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
+ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
 
 
 #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index eb55a69..738f1eb 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -5,8 +5,8 @@
 #include <nginx.h>
 
 
-static int ngx_http_header_filter_init(ngx_cycle_t *cycle);
-static int ngx_http_header_filter(ngx_http_request_t *r);
+static ngx_int_t ngx_http_header_filter_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r);
 
 
 static ngx_http_module_t  ngx_http_header_filter_module_ctx = {
@@ -90,7 +90,7 @@
 
 
 
-static int ngx_http_header_filter(ngx_http_request_t *r)
+static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
 {
     u_char            *p;
     size_t             len;
@@ -359,7 +359,7 @@
 }
 
 
-static int ngx_http_header_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_header_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_top_header_filter = ngx_http_header_filter;
 
diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c
index 908d6fc..727cceb 100644
--- a/src/http/ngx_http_log_handler.c
+++ b/src/http/ngx_http_log_handler.c
@@ -35,7 +35,7 @@
 static u_char *ngx_http_log_unknown_header_out(ngx_http_request_t *r, u_char *buf,
                                                uintptr_t data);
 
-static int ngx_http_log_pre_conf(ngx_conf_t *cf);
+static ngx_int_t ngx_http_log_pre_conf(ngx_conf_t *cf);
 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf);
 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf);
 static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent,
@@ -44,8 +44,8 @@
                                   void *conf);
 static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd,
                                      void *conf);
-static int ngx_http_log_parse_format(ngx_conf_t *cf, ngx_array_t *ops,
-                                     ngx_str_t *line);
+static ngx_int_t ngx_http_log_parse_format(ngx_conf_t *cf, ngx_array_t *ops,
+                                           ngx_str_t *line);
 
 
 static ngx_command_t  ngx_http_log_commands[] = {
@@ -116,7 +116,7 @@
 };
 
 
-int ngx_http_log_handler(ngx_http_request_t *r)
+ngx_int_t ngx_http_log_handler(ngx_http_request_t *r)
 {
     ngx_uint_t                i, l;
     uintptr_t                 data;
@@ -198,7 +198,8 @@
 static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
                                      uintptr_t data)
 {
-    return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 1, "%u",
+    return buf + ngx_snprintf((char *) buf, NGX_INT_T_LEN + 1,
+                              "%" NGX_UINT_T_FMT,
                               r->connection->number);
 }
 
@@ -239,7 +240,7 @@
 static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf,
                                    uintptr_t data)
 {
-    return buf + ngx_snprintf((char *) buf, 4, "%d",
+    return buf + ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT,
                         r->err_status ? r->err_status : r->headers_out.status);
 }
 
@@ -561,7 +562,7 @@
 }
 
 
-static int ngx_http_log_pre_conf(ngx_conf_t *cf)
+static ngx_int_t ngx_http_log_pre_conf(ngx_conf_t *cf)
 {
     ngx_http_log_op_name_t  *op;
 
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 98fbc28..3f50666 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -9,13 +9,13 @@
 static void ngx_http_process_request_line(ngx_event_t *rev);
 static void ngx_http_process_request_headers(ngx_event_t *rev);
 static ssize_t ngx_http_read_request_header(ngx_http_request_t *r);
-static int ngx_http_process_request_header(ngx_http_request_t *r);
+static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r);
 
 static void ngx_http_set_write_handler(ngx_http_request_t *r);
 
 static void ngx_http_block_read(ngx_event_t *ev);
 static void ngx_http_read_discarded_body_event(ngx_event_t *rev);
-static int ngx_http_read_discarded_body(ngx_http_request_t *r);
+static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r);
 
 static void ngx_http_set_keepalive(ngx_http_request_t *r);
 static void ngx_http_keepalive_handler(ngx_event_t *ev);
@@ -847,6 +847,7 @@
 
 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
 {
+    u_char                    *ua;
     size_t                     len;
     ngx_uint_t                 i;
     ngx_http_server_name_t    *name;
@@ -935,6 +936,25 @@
         }
     }
 
+    if (r->headers_in.user_agent) {
+
+        /*
+         * check some widespread browsers while the headers are still
+         * in CPU cache
+         */
+
+        ua = ngx_strstr(r->headers_in.user_agent->value.data, "MSIE");
+        if (ua
+            && ua + 8 < r->headers_in.user_agent->value.data
+                                         + r->headers_in.user_agent->value.len)
+        {
+            r->headers_in.msie = 1;
+            if (ua[4] == ' ' && ua[5] == '4' && ua[6] == '.') {
+                r->headers_in.msie4 = 1;
+            }
+        }
+    }
+
     return NGX_OK;
 }
 
@@ -1116,7 +1136,7 @@
 }
 
 
-int ngx_http_discard_body(ngx_http_request_t *r)
+ngx_int_t ngx_http_discard_body(ngx_http_request_t *r)
 {
     ssize_t       size;
     ngx_event_t  *rev;
@@ -1182,7 +1202,7 @@
 }
 
 
-static int ngx_http_read_discarded_body(ngx_http_request_t *r)
+static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r)
 {
     ssize_t                    size, n;
     ngx_http_core_loc_conf_t  *clcf;
@@ -1523,7 +1543,7 @@
 }
 
 
-int ngx_http_send_last(ngx_http_request_t *r)
+ngx_int_t ngx_http_send_last(ngx_http_request_t *r)
 {
     ngx_buf_t    *b;
     ngx_chain_t   out;
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 3cf7307..52e110a 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -135,6 +135,9 @@
     ssize_t           content_length_n;
     size_t            connection_type;
     ssize_t           keep_alive_n;
+
+    unsigned          msie;
+    unsigned          msie4;
 } ngx_http_headers_in_t;
 
 
@@ -201,7 +204,7 @@
 };
 
 
-typedef int (*ngx_http_handler_pt)(ngx_http_request_t *r);
+typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r);
 
 struct ngx_http_request_s {
     ngx_connection_t         *connection;
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 2e26640..70a6bb8 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -177,10 +177,10 @@
 };
 
 
-int ngx_http_special_response_handler(ngx_http_request_t *r, int error)
+ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r, int error)
 {
     ngx_int_t                  rc;
-    ngx_uint_t                 err, i;
+    ngx_uint_t                 err, i, msie_padding;
     ngx_buf_t                 *b;
     ngx_chain_t               *out, **ll, *cl;
     ngx_http_err_page_t       *err_page;
@@ -248,16 +248,20 @@
         }
     }
 
+    msie_padding = 0;
+
     if (error_pages[err].len) {
         r->headers_out.content_length_n = error_pages[err].len
                                           + sizeof(error_tail) - 1;
 
         if (clcf->msie_padding
+            && r->headers_in.msie
             && r->http_version >= NGX_HTTP_VERSION_10
             && error >= NGX_HTTP_BAD_REQUEST
             && error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
         {
             r->headers_out.content_length_n += sizeof(msie_stub) - 1;
+            msie_padding = 1;
         }
 
         if (!(r->headers_out.content_type =
@@ -314,11 +318,7 @@
     ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR);
     ngx_chain_add_link(out, ll, cl);
 
-    if (clcf->msie_padding
-        && r->http_version >= NGX_HTTP_VERSION_10
-        && error >= NGX_HTTP_BAD_REQUEST
-        && error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
-    {
+    if (msie_padding) {
         if (!(b = ngx_calloc_buf(r->pool))) {
             return NGX_ERROR;
         }
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index 48aba43..b0e4737 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -18,7 +18,7 @@
 static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf);
 static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf,
                                               void *parent, void *child);
-static int ngx_http_write_filter_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle);
 
 
 static ngx_command_t  ngx_http_write_filter_commands[] = {
@@ -66,7 +66,7 @@
 };
 
 
-int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
+ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
 {
     int                            last;
     off_t                          size, flush;
@@ -196,7 +196,7 @@
 }
 
 
-static int ngx_http_write_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_top_body_filter = ngx_http_write_filter;