summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-06-02 16:22:32 +0000
committerJonathan Kolb <jon@b0g.us>2009-06-02 16:22:32 +0000
commit48a71b870032c0787bc31650f3143465a4cd417b (patch)
treecdbc3eed0e6881d3632461f027b2547ab3b12f17
parent8e691fc5d70edca2a685bc341bbef7a097371349 (diff)
downloadnginx-0.8.0.tar.gz
Changes with nginx 0.8.0 02 Jun 2009v0.8.0
*) Feature: the "keepalive_requests" directive. *) Feature: the "limit_rate_after" directive. Thanks to Ivan Debnar. *) Bugfix: XLST filter did not work in subrequests. *) Bugfix: in relative paths handling in nginx/Windows. *) Bugfix: in proxy_store, fastcgi_store, proxy_cache, and fastcgi_cache in nginx/Windows. *) Bugfix: in memory allocation error handling. Thanks to Maxim Dounin and Kirill A. Korinskiy.
-rw-r--r--CHANGES18
-rw-r--r--CHANGES.ru18
-rw-r--r--auto/cc/msvc2
-rw-r--r--auto/lib/conf18
-rw-r--r--auto/lib/google-perftools/conf11
-rw-r--r--auto/lib/md5/conf12
-rw-r--r--auto/lib/openssl/conf11
-rw-r--r--auto/lib/openssl/make23
-rw-r--r--auto/lib/pcre/conf12
-rw-r--r--auto/lib/zlib/conf11
-rw-r--r--auto/summary59
-rw-r--r--src/core/nginx.h4
-rw-r--r--src/core/ngx_conf_file.c95
-rw-r--r--src/core/ngx_connection.h2
-rw-r--r--src/core/ngx_cycle.c22
-rw-r--r--src/core/ngx_file.c10
-rw-r--r--src/core/ngx_output_chain.c5
-rw-r--r--src/core/ngx_slab.h1
-rw-r--r--src/event/modules/ngx_devpoll_module.c2
-rw-r--r--src/event/modules/ngx_epoll_module.c2
-rw-r--r--src/event/modules/ngx_eventport_module.c2
-rw-r--r--src/event/modules/ngx_kqueue_module.c2
-rw-r--r--src/event/modules/ngx_rtsig_module.c2
-rw-r--r--src/event/ngx_event.c4
-rw-r--r--src/event/ngx_event_openssl.c2
-rw-r--r--src/http/modules/ngx_http_access_module.c2
-rw-r--r--src/http/modules/ngx_http_addition_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_auth_basic_module.c2
-rw-r--r--src/http/modules/ngx_http_autoindex_module.c16
-rw-r--r--src/http/modules/ngx_http_browser_module.c2
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c394
-rw-r--r--src/http/modules/ngx_http_dav_module.c2
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c29
-rw-r--r--src/http/modules/ngx_http_gzip_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_gzip_static_module.c2
-rw-r--r--src/http/modules/ngx_http_headers_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_image_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_index_module.c2
-rw-r--r--src/http/modules/ngx_http_limit_req_module.c2
-rw-r--r--src/http/modules/ngx_http_limit_zone_module.c2
-rw-r--r--src/http/modules/ngx_http_log_module.c10
-rw-r--r--src/http/modules/ngx_http_map_module.c2
-rw-r--r--src/http/modules/ngx_http_memcached_module.c2
-rw-r--r--src/http/modules/ngx_http_proxy_module.c29
-rw-r--r--src/http/modules/ngx_http_random_index_module.c2
-rw-r--r--src/http/modules/ngx_http_realip_module.c2
-rw-r--r--src/http/modules/ngx_http_referer_module.c2
-rw-r--r--src/http/modules/ngx_http_rewrite_module.c2
-rw-r--r--src/http/modules/ngx_http_secure_link_module.c2
-rw-r--r--src/http/modules/ngx_http_ssi_filter_module.c6
-rw-r--r--src/http/modules/ngx_http_ssl_module.c2
-rw-r--r--src/http/modules/ngx_http_sub_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_userid_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_xslt_filter_module.c13
-rw-r--r--src/http/modules/perl/nginx.pm2
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c4
-rw-r--r--src/http/ngx_http_core_module.c42
-rw-r--r--src/http/ngx_http_core_module.h2
-rw-r--r--src/http/ngx_http_request.c11
-rw-r--r--src/http/ngx_http_request.h1
-rw-r--r--src/http/ngx_http_script.c2
-rw-r--r--src/http/ngx_http_upstream.c2
-rw-r--r--src/http/ngx_http_write_filter_module.c23
-rw-r--r--src/mail/ngx_mail_auth_http_module.c2
-rw-r--r--src/mail/ngx_mail_core_module.c6
-rw-r--r--src/mail/ngx_mail_proxy_module.c2
-rw-r--r--src/mail/ngx_mail_ssl_module.c2
67 files changed, 629 insertions, 363 deletions
diff --git a/CHANGES b/CHANGES
index 22aae44d8..3f2ae5259 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,22 @@
+Changes with nginx 0.8.0 02 Jun 2009
+
+ *) Feature: the "keepalive_requests" directive.
+
+ *) Feature: the "limit_rate_after" directive.
+ Thanks to Ivan Debnar.
+
+ *) Bugfix: XLST filter did not work in subrequests.
+
+ *) Bugfix: in relative paths handling in nginx/Windows.
+
+ *) Bugfix: in proxy_store, fastcgi_store, proxy_cache, and
+ fastcgi_cache in nginx/Windows.
+
+ *) Bugfix: in memory allocation error handling.
+ Thanks to Maxim Dounin and Kirill A. Korinskiy.
+
+
Changes with nginx 0.7.59 25 May 2009
*) Feature: the "proxy_cache_methods" and "fastcgi_cache_methods"
diff --git a/CHANGES.ru b/CHANGES.ru
index 8b9e6a441..673a71cba 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,22 @@
+Изменения в nginx 0.8.0 02.06.2009
+
+ *) Добавление: директива keepalive_requests.
+
+ *) Добавление: директива limit_rate_after.
+ Спасибо Ivan Debnar.
+
+ *) Исправление: XSLT-фильтр не работал в подзапросах.
+
+ *) Исправление: обработке относительных путей в in nginx/Windows.
+
+ *) Исправление: в proxy_store, fastcgi_store, proxy_cache и
+ fastcgi_cache в nginx/Windows.
+
+ *) Исправление: в обработке ошибок выделения памяти.
+ Спасибо Максиму Дунину и Кириллу Коринскому.
+
+
Изменения в nginx 0.7.59 25.05.2009
*) Добавление: директивы proxy_cache_methods и fastcgi_cache_methods.
diff --git a/auto/cc/msvc b/auto/cc/msvc
index 11c4682cf..01d6f7f2f 100644
--- a/auto/cc/msvc
+++ b/auto/cc/msvc
@@ -125,7 +125,7 @@ ngx_objext="obj"
ngx_binext=".exe"
ngx_long_start='@<<
- '
+ '
ngx_long_end='<<'
ngx_long_regex_cont=' \
'
diff --git a/auto/lib/conf b/auto/lib/conf
index a4155e1ba..f52c90492 100644
--- a/auto/lib/conf
+++ b/auto/lib/conf
@@ -4,15 +4,29 @@
if [ $USE_PCRE = YES -o $PCRE != NONE ]; then
. auto/lib/pcre/conf
+
+else
+ if [ $USE_PCRE = DISABLED -a $HTTP_REWRITE = YES ]; then
+
+cat << END
+
+$0: error: the HTTP rewrite module requires the PCRE library.
+You can either disable the module by using --without-http_rewrite_module
+option or you have to enable the PCRE support.
+
+END
+ exit 1
+ fi
fi
+
if [ $USE_OPENSSL = YES ]; then
. auto/lib/openssl/conf
fi
if [ $USE_MD5 = YES ]; then
- if [ $OPENSSL != NONE -a $OPENSSL != NO ]; then
+ if [ $USE_OPENSSL = YES ]; then
have=NGX_HAVE_OPENSSL_MD5_H . auto/have
have=NGX_OPENSSL_MD5 . auto/have
MD5=YES
@@ -26,7 +40,7 @@ fi
if [ $USE_SHA1 = YES ]; then
- if [ $OPENSSL != NONE -a $OPENSSL != NO ]; then
+ if [ $USE_OPENSSL = YES ]; then
have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
SHA1=YES
SHA1_LIB=OpenSSL
diff --git a/auto/lib/google-perftools/conf b/auto/lib/google-perftools/conf
index a8987c908..67df9f8ac 100644
--- a/auto/lib/google-perftools/conf
+++ b/auto/lib/google-perftools/conf
@@ -30,4 +30,15 @@ fi
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+
+else
+
+cat << END
+
+$0: error: the Google perftool module requires the Google perftools
+library. You can either do not enable the module or install the library.
+
+END
+
+ exit 1
fi
diff --git a/auto/lib/md5/conf b/auto/lib/md5/conf
index 75dd1300e..d4ef0070e 100644
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -94,6 +94,18 @@ else
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES
MD5_LIB=$ngx_md5_lib
+ else
+
+cat << END
+
+$0: error: the HTTP cache module requires md5 functions
+from OpenSSL library. You can either disable the module by using
+--without-http_cache option, or install the OpenSSL library into the system,
+or build the OpenSSL library statically from the source with nginx by using
+--with-openssl=<path> option.
+
+END
+ exit 1
fi
fi
diff --git a/auto/lib/openssl/conf b/auto/lib/openssl/conf
index 8a762a2fc..731db80d7 100644
--- a/auto/lib/openssl/conf
+++ b/auto/lib/openssl/conf
@@ -66,6 +66,17 @@ else
have=NGX_SSL . auto/have
CORE_LIBS="$CORE_LIBS $ngx_feature_libs $NGX_LIBDL"
OPENSSL=YES
+ else
+
+cat << END
+
+$0: error: SSL modules require the OpenSSL library.
+You can either do not enable the modules, or install the OpenSSL library
+into the system, or build the OpenSSL library statically from the source
+with nginx by using --with-openssl=<path> option.
+
+END
+ exit 1
fi
;;
diff --git a/auto/lib/openssl/make b/auto/lib/openssl/make
index 6646cb2a4..3c21f436b 100644
--- a/auto/lib/openssl/make
+++ b/auto/lib/openssl/make
@@ -2,11 +2,6 @@
# Copyright (C) Igor Sysoev
-case $USE_THREADS in
- NO) OPENSSL_OPT="$OPENSSL_OPT no-threads" ;;
- *) OPENSSL_OPT="$OPENSSL_OPT threads" ;;
-esac
-
case "$CC" in
cl)
@@ -21,7 +16,7 @@ END
;;
- cl | bcc32)
+ bcc32)
ngx_opt=`echo "-DOPENSSL=\"$OPENSSL\" -DOPENSSL_OPT=\"$OPENSSL_OPT\"" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
@@ -45,16 +40,14 @@ END
;;
*)
- case $OPENSSL in
-
- /*)
- ngx_prefix="$OPENSSL/openssl"
- ;;
-
- *)
- ngx_prefix="$PWD/$OPENSSL/openssl"
- ;;
+ case $USE_THREADS in
+ NO) OPENSSL_OPT="$OPENSSL_OPT no-threads" ;;
+ *) OPENSSL_OPT="$OPENSSL_OPT threads" ;;
+ esac
+ case $OPENSSL in
+ /*) ngx_prefix="$OPENSSL/openssl" ;;
+ *) ngx_prefix="$PWD/$OPENSSL/openssl" ;;
esac
cat << END >> $NGX_MAKEFILE
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
index 3a26b858f..71c6fc5f7 100644
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -161,6 +161,18 @@ else
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
+ else
+
+cat << END
+
+$0: error: the HTTP rewrite module requires the PCRE library.
+You can either disable the module by using --without-http_rewrite_module
+option, or install the PCRE library into the system, or build the PCRE library
+statically from the source with nginx by using --with-pcre=<path> option.
+
+END
+ exit 1
+
fi
fi
diff --git a/auto/lib/zlib/conf b/auto/lib/zlib/conf
index f033354a4..e44aa3424 100644
--- a/auto/lib/zlib/conf
+++ b/auto/lib/zlib/conf
@@ -57,6 +57,17 @@ else
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
ZLIB=YES
ngx_found=no
+ else
+
+cat << END
+
+$0: error: the HTTP gzip module requires the zlib library.
+You can either disable the module by using --without-http_gzip_module
+option, or install the zlib library into the system, or build the zlib library
+statically from the source with nginx by using --with-zlib=<path> option.
+
+END
+ exit 1
fi
fi
diff --git a/auto/summary b/auto/summary
index bcb8bcd12..b0f6b1974 100644
--- a/auto/summary
+++ b/auto/summary
@@ -74,65 +74,6 @@ esac
echo
-if [ $HTTP_REWRITE = YES ]; then
- if [ $USE_PCRE = DISABLED ]; then
-
-cat << END
-$0: error: the HTTP rewrite module requires the PCRE library.
-You can either disable the module by using --without-http_rewrite_module
-option or you have to enable the PCRE support.
-
-END
- exit 1
- fi
-
- if [ $PCRE = NONE -o $PCRE = NO ]; then
-
-cat << END
-$0: error: the HTTP rewrite module requires the PCRE library.
-You can either disable the module by using --without-http_rewrite_module
-option, or install the PCRE library into the system, or build the PCRE library
-statically from the source with nginx by using --with-pcre=<path> option.
-
-END
-
- exit 1
- fi
-fi
-
-
-if [ $HTTP_GZIP = YES ]; then
- if [ $ZLIB = NONE -o $ZLIB = NO ]; then
-
-cat << END
-$0: error: the HTTP gzip module requires the zlib library.
-You can either disable the module by using --without-http_gzip_module
-option, or install the zlib library into the system, or build the zlib library
-statically from the source with nginx by using --with-zlib=<path> option.
-
-END
-
- exit 1
- fi
-fi
-
-
-if [ $HTTP_SSL = YES ]; then
- if [ $OPENSSL = NONE -o $OPENSSL = NO ]; then
-
-cat << END
-$0: error: the HTTP SSL module requires the OpenSSL library.
-You can either do not enable the module, or install the OpenSSL library
-into the system, or build the OpenSSL library statically from the source
-with nginx by using --with-openssl=<path> option.
-
-END
-
- exit 1
- fi
-fi
-
-
cat << END
nginx path prefix: "$NGX_PREFIX"
nginx binary file: "$NGX_SBIN_PATH"
diff --git a/src/core/nginx.h b/src/core/nginx.h
index f642321fa..f72a6fbfb 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,8 +8,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 7059
-#define NGINX_VERSION "0.7.59"
+#define nginx_version 8000
+#define NGINX_VERSION "0.8.0"
#define NGINX_VER "nginx/" NGINX_VERSION
#define NGINX_VAR "NGINX"
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 1f6b1f732..c58d8095f 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -12,6 +12,7 @@
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static ngx_int_t ngx_conf_test_full_name(ngx_str_t *name);
static void ngx_conf_flush_files(ngx_cycle_t *cycle);
@@ -802,29 +803,15 @@ ngx_int_t
ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
{
size_t len;
- u_char *p, *prefix;
- ngx_str_t old;
+ u_char *p, *n, *prefix;
+ ngx_int_t rc;
-#if (NGX_WIN32)
+ rc = ngx_conf_test_full_name(name);
- if (name->len > 2
- && name->data[1] == ':'
- && ((name->data[0] >= 'a' && name->data[0] <= 'z')
- || (name->data[0] >= 'A' && name->data[0] <= 'Z')))
- {
- return NGX_OK;
+ if (rc == NGX_OK) {
+ return rc;
}
-#else
-
- if (name->data[0] == '/') {
- return NGX_OK;
- }
-
-#endif
-
- old = *name;
-
if (conf_prefix) {
len = cycle->conf_prefix.len;
prefix = cycle->conf_prefix.data;
@@ -834,19 +821,79 @@ ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
prefix = cycle->prefix.data;
}
- name->len = len + old.len;
- name->data = ngx_pnalloc(cycle->pool, name->len + 1);
- if (name->data == NULL) {
+#if (NGX_WIN32)
+
+ if (rc == 2) {
+ len = rc;
+ }
+
+#endif
+
+ n = ngx_pnalloc(cycle->pool, len + name->len + 1);
+ if (n == NULL) {
return NGX_ERROR;
}
- p = ngx_cpymem(name->data, prefix, len);
- ngx_cpystrn(p, old.data, old.len + 1);
+ p = ngx_cpymem(n, prefix, len);
+ ngx_cpystrn(p, name->data, name->len + 1);
+
+ name->len += len;
+ name->data = n;
return NGX_OK;
}
+static ngx_int_t
+ngx_conf_test_full_name(ngx_str_t *name)
+{
+#if (NGX_WIN32)
+ u_char c0, c1;
+
+ c0 = name->data[0];
+
+ if (name->len < 2) {
+ if (c0 == '/') {
+ return 2;
+ }
+
+ return NGX_DECLINED;
+ }
+
+ c1 = name->data[1];
+
+ if (c1 == ':') {
+ c0 |= 0x20;
+
+ if ((c0 >= 'a' && c0 <= 'z')) {
+ return NGX_OK;
+ }
+
+ return NGX_DECLINED;
+ }
+
+ if (c1 == '/') {
+ return NGX_OK;
+ }
+
+ if (c0 == '/') {
+ return 2;
+ }
+
+ return NGX_DECLINED;
+
+#else
+
+ if (name->data[0] == '/') {
+ return NGX_OK;
+ }
+
+ return NGX_DECLINED;
+
+#endif
+}
+
+
ngx_open_file_t *
ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
{
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index 5fd7a5ead..689b5f0e9 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -135,6 +135,8 @@ struct ngx_connection_s {
ngx_atomic_uint_t number;
+ ngx_uint_t requests;
+
unsigned buffered:8;
unsigned log_error:3; /* ngx_connection_log_error_e */
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index fc65765b0..63eec1459 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -216,7 +216,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
if (module->create_conf) {
rv = module->create_conf(cycle);
- if (rv == NGX_CONF_ERROR) {
+ if (rv == NULL) {
ngx_destroy_pool(pool);
return NULL;
}
@@ -463,11 +463,8 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
goto failed;
}
- if (!shm_zone[i].shm.exists) {
-
- if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
- goto failed;
- }
+ if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
+ goto failed;
}
if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
@@ -885,8 +882,21 @@ ngx_init_zone_pool(ngx_cycle_t *cycle, ngx_shm_zone_t *zn)
sp = (ngx_slab_pool_t *) zn->shm.addr;
+ if (zn->shm.exists) {
+
+ if (sp == sp->addr) {
+ return NGX_OK;
+ }
+
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+ "shared zone \"%V\" has no equal addresses: %p vs %p",
+ &zn->shm.name, sp->addr, sp);
+ return NGX_ERROR;
+ }
+
sp->end = zn->shm.addr + zn->shm.size;
sp->min_shift = 3;
+ sp->addr = zn->shm.addr;
#if (NGX_HAVE_ATOMIC_OPS)
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 450da5623..3f47fc98b 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -558,8 +558,14 @@ ngx_ext_rename_file(ngx_str_t *src, ngx_str_t *to, ngx_ext_rename_file_t *ext)
err = ngx_errno;
- if (err == NGX_ENOENT) {
-
+ if (err
+#if (NGX_WIN32)
+ == ERROR_PATH_NOT_FOUND
+#else
+ == NGX_ENOENT
+#endif
+ )
+ {
if (!ext->create_path) {
goto failed;
}
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 71016996d..6d6d241c1 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -314,12 +314,11 @@ ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
#endif
+ cl->next = NULL;
*ll = cl;
ll = &cl->next;
}
- *ll = NULL;
-
return NGX_OK;
}
@@ -503,6 +502,7 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
if (src->pos == src->last) {
dst->flush = src->flush;
dst->last_buf = src->last_buf;
+ dst->last_in_chain = src->last_in_chain;
}
} else {
@@ -577,6 +577,7 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
if (src->file_pos == src->file_last) {
dst->flush = src->flush;
dst->last_buf = src->last_buf;
+ dst->last_in_chain = src->last_in_chain;
}
}
diff --git a/src/core/ngx_slab.h b/src/core/ngx_slab.h
index 89c4687f6..291e1b51e 100644
--- a/src/core/ngx_slab.h
+++ b/src/core/ngx_slab.h
@@ -39,6 +39,7 @@ typedef struct {
u_char zero;
void *data;
+ void *addr;
} ngx_slab_pool_t;
diff --git a/src/event/modules/ngx_devpoll_module.c b/src/event/modules/ngx_devpoll_module.c
index 903efe6b5..657886268 100644
--- a/src/event/modules/ngx_devpoll_module.c
+++ b/src/event/modules/ngx_devpoll_module.c
@@ -550,7 +550,7 @@ ngx_devpoll_create_conf(ngx_cycle_t *cycle)
dpcf = ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t));
if (dpcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
dpcf->changes = NGX_CONF_UNSET;
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
index 71d847107..b3267b37d 100644
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -552,7 +552,7 @@ ngx_epoll_create_conf(ngx_cycle_t *cycle)
epcf = ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t));
if (epcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
epcf->events = NGX_CONF_UNSET;
diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c
index 4becf75d0..842d631af 100644
--- a/src/event/modules/ngx_eventport_module.c
+++ b/src/event/modules/ngx_eventport_module.c
@@ -581,7 +581,7 @@ ngx_eventport_create_conf(ngx_cycle_t *cycle)
epcf = ngx_palloc(cycle->pool, sizeof(ngx_eventport_conf_t));
if (epcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
epcf->events = NGX_CONF_UNSET;
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index 1ad2d8d5a..a84fc8fe1 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -768,7 +768,7 @@ ngx_kqueue_create_conf(ngx_cycle_t *cycle)
kcf = ngx_palloc(cycle->pool, sizeof(ngx_kqueue_conf_t));
if (kcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
kcf->changes = NGX_CONF_UNSET;
diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c
index 6020936b7..926be0de3 100644
--- a/src/event/modules/ngx_rtsig_module.c
+++ b/src/event/modules/ngx_rtsig_module.c
@@ -691,7 +691,7 @@ ngx_rtsig_create_conf(ngx_cycle_t *cycle)
rtscf = ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t));
if (rtscf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
rtscf->signo = NGX_CONF_UNSET;
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index e30c5636a..7fc690115 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -1113,7 +1113,7 @@ ngx_event_create_conf(ngx_cycle_t *cycle)
ecf = ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t));
if (ecf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
ecf->connections = NGX_CONF_UNSET_UINT;
@@ -1128,7 +1128,7 @@ ngx_event_create_conf(ngx_cycle_t *cycle)
if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4,
sizeof(ngx_event_debug_t)) == NGX_ERROR)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
#endif
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
index 23a4fbec4..1607814ce 100644
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -2115,7 +2115,7 @@ ngx_openssl_create_conf(ngx_cycle_t *cycle)
oscf = ngx_pcalloc(cycle->pool, sizeof(ngx_openssl_conf_t));
if (oscf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_access_module.c b/src/http/modules/ngx_http_access_module.c
index 78b8a6a10..405aad4ef 100644
--- a/src/http/modules/ngx_http_access_module.c
+++ b/src/http/modules/ngx_http_access_module.c
@@ -201,7 +201,7 @@ ngx_http_access_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_access_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
return conf;
diff --git a/src/http/modules/ngx_http_addition_filter_module.c b/src/http/modules/ngx_http_addition_filter_module.c
index eb6a4b168..4076c5374 100644
--- a/src/http/modules/ngx_http_addition_filter_module.c
+++ b/src/http/modules/ngx_http_addition_filter_module.c
@@ -212,7 +212,7 @@ ngx_http_addition_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_addition_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_auth_basic_module.c b/src/http/modules/ngx_http_auth_basic_module.c
index 1d2d75e73..c9ce694ef 100644
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -372,7 +372,7 @@ ngx_http_auth_basic_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_auth_basic_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
return conf;
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index 6215da21f..698b7636c 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -145,7 +145,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
ngx_int_t rc, size;
ngx_str_t path;
ngx_dir_t dir;
- ngx_uint_t i, level;
+ ngx_uint_t i, level, utf8;
ngx_pool_t *pool;
ngx_time_t *tp;
ngx_chain_t out;
@@ -252,6 +252,16 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
filename = path.data;
filename[path.len] = '/';
+ if (r->headers_out.charset.len == 5
+ && ngx_strncasecmp(r->headers_out.charset.data, (u_char *) "utf-8", 5)
+ == 0)
+ {
+ utf8 = 1;
+
+ } else {
+ utf8 = 0;
+ }
+
for ( ;; ) {
ngx_set_errno(0);
@@ -335,7 +345,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len,
NGX_ESCAPE_HTML);
- if (r->utf8) {
+ if (utf8) {
entry->utf_len = ngx_utf8_length(entry->name.data, entry->name.len);
} else {
entry->utf_len = len;
@@ -622,7 +632,7 @@ ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf)
conf = ngx_palloc(cf->pool, sizeof(ngx_http_autoindex_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
conf->enable = NGX_CONF_UNSET;
diff --git a/src/http/modules/ngx_http_browser_module.c b/src/http/modules/ngx_http_browser_module.c
index e0710c1bf..d400fec7f 100644
--- a/src/http/modules/ngx_http_browser_module.c
+++ b/src/http/modules/ngx_http_browser_module.c
@@ -423,7 +423,7 @@ ngx_http_browser_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_browser_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index 4efbce76d..a76499181 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -9,8 +9,9 @@
#include <ngx_http.h>
-#define NGX_HTTP_NO_CHARSET -2
-#define NGX_HTTP_CHARSET_VAR 0x10000
+#define NGX_HTTP_CHARSET_OFF -2
+#define NGX_HTTP_NO_CHARSET -3
+#define NGX_HTTP_CHARSET_VAR 0x10000
/* 1 byte length and up to 3 bytes for the UTF-8 encoding of the UCS-2 */
#define NGX_UTF_LEN 4
@@ -61,6 +62,7 @@ typedef struct {
typedef struct {
u_char *table;
ngx_int_t charset;
+ ngx_str_t charset_name;
ngx_chain_t *busy;
ngx_chain_t *free_bufs;
@@ -82,9 +84,16 @@ typedef struct {
} ngx_http_charset_conf_ctx_t;
-static ngx_int_t ngx_http_charset_get_charset(ngx_http_charset_t *charsets,
- ngx_uint_t n, ngx_str_t *charset);
-static ngx_int_t ngx_http_charset_set_charset(ngx_http_request_t *r,
+static ngx_int_t ngx_http_destination_charset(ngx_http_request_t *r,
+ ngx_str_t *name);
+static ngx_int_t ngx_http_main_request_charset(ngx_http_request_t *r,
+ ngx_str_t *name);
+static ngx_int_t ngx_http_source_charset(ngx_http_request_t *r,
+ ngx_str_t *name);
+static ngx_int_t ngx_http_get_charset(ngx_http_request_t *r, ngx_str_t *name);
+static ngx_inline void ngx_http_set_charset(ngx_http_request_t *r,
+ ngx_str_t *charset);
+static ngx_int_t ngx_http_charset_ctx(ngx_http_request_t *r,
ngx_http_charset_t *charsets, ngx_int_t charset, ngx_int_t source_charset);
static ngx_uint_t ngx_http_charset_recode(ngx_buf_t *b, u_char *table);
static ngx_chain_t *ngx_http_charset_recode_from_utf8(ngx_pool_t *pool,
@@ -207,207 +216,264 @@ static ngx_int_t
ngx_http_charset_header_filter(ngx_http_request_t *r)
{
ngx_int_t charset, source_charset;
- ngx_str_t *mc, *from, *to, s;
- ngx_uint_t n;
+ ngx_str_t dst, src;
ngx_http_charset_t *charsets;
- ngx_http_charset_ctx_t *ctx;
- ngx_http_variable_value_t *vv;
- ngx_http_charset_loc_conf_t *lcf, *mlcf;
ngx_http_charset_main_conf_t *mcf;
- mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
+ if (r == r->main) {
+ charset = ngx_http_destination_charset(r, &dst);
- charsets = mcf->charsets.elts;
- n = mcf->charsets.nelts;
+ } else {
+ charset = ngx_http_main_request_charset(r, &dst);
+ }
- /* destination charset */
+ if (charset == NGX_ERROR) {
+ return NGX_ERROR;
+ }
- if (r == r->main) {
+ if (charset == NGX_DECLINED) {
+ return ngx_http_next_header_filter(r);
+ }
+
+ /* charset: charset index or NGX_HTTP_NO_CHARSET */
+
+ source_charset = ngx_http_source_charset(r, &src);
+
+ if (source_charset == NGX_ERROR) {
+ return NGX_ERROR;
+ }
+
+ /*
+ * source_charset: charset index, NGX_HTTP_NO_CHARSET,
+ * or NGX_HTTP_CHARSET_OFF
+ */
+
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "charset: \"%V\" > \"%V\"", &src, &dst);
- if (!r->ignore_content_encoding
- && r->headers_out.content_encoding
- && r->headers_out.content_encoding->value.len)
+ if (source_charset == NGX_HTTP_CHARSET_OFF) {
+ ngx_http_set_charset(r, &dst);
+
+ return ngx_http_next_header_filter(r);
+ }
+
+ if (charset == NGX_HTTP_NO_CHARSET
+ || source_charset == NGX_HTTP_NO_CHARSET)
+ {
+ if (source_charset != charset
+ || ngx_strncasecmp(dst.data, src.data, dst.len) != 0)
{
- return ngx_http_next_header_filter(r);
+ goto no_charset_map;
}
- if (r->headers_out.content_type.len == 0) {
- return ngx_http_next_header_filter(r);
- }
+ ngx_http_set_charset(r, &dst);
- if (r->headers_out.override_charset
- && r->headers_out.override_charset->len)
- {
- charset = ngx_http_charset_get_charset(charsets, n,
- r->headers_out.override_charset);
+ return ngx_http_next_header_filter(r);
+ }
- if (charset == NGX_HTTP_NO_CHARSET) {
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "unknown charset \"%V\" to override",
- r->headers_out.override_charset);
+ mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
+ charsets = mcf->charsets.elts;
- return ngx_http_next_header_filter(r);
- }
+ if (source_charset != charset
+ && (charsets[source_charset].tables == NULL
+ || charsets[source_charset].tables[charset] == NULL))
+ {
+ goto no_charset_map;
+ }
- } else {
- mlcf = ngx_http_get_module_loc_conf(r,
- ngx_http_charset_filter_module);
- charset = mlcf->charset;
+ r->headers_out.content_type.len = r->headers_out.content_type_len;
- if (charset == NGX_HTTP_NO_CHARSET) {
- return ngx_http_next_header_filter(r);
- }
+ ngx_http_set_charset(r, &dst);
- if (r->headers_out.charset.len) {
- if (mlcf->override_charset == 0) {
- return ngx_http_next_header_filter(r);
- }
+ if (source_charset != charset) {
+ return ngx_http_charset_ctx(r, charsets, charset, source_charset);
+ }
- } else {
- if (ngx_http_test_content_type(r, &mlcf->types) == NULL) {
- return ngx_http_next_header_filter(r);
- }
- }
+ return ngx_http_next_header_filter(r);
- if (charset >= NGX_HTTP_CHARSET_VAR) {
- vv = ngx_http_get_indexed_variable(r,
- charset - NGX_HTTP_CHARSET_VAR);
+no_charset_map:
- if (vv == NULL || vv->not_found) {
- return NGX_ERROR;
- }
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "no \"charset_map\" between the charsets \"%V\" and \"%V\"",
+ &src, &dst);
- s.len = vv->len;
- s.data = vv->data;
+ return ngx_http_next_header_filter(r);
+}
- charset = ngx_http_charset_get_charset(charsets, n, &s);
- }
- }
- } else {
- ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module);
+static ngx_int_t
+ngx_http_destination_charset(ngx_http_request_t *r, ngx_str_t *name)
+{
+ ngx_int_t charset;
+ ngx_http_charset_t *charsets;
+ ngx_http_variable_value_t *vv;
+ ngx_http_charset_loc_conf_t *mlcf;
+ ngx_http_charset_main_conf_t *mcf;
- if (ctx == NULL) {
+ if (!r->ignore_content_encoding
+ && r->headers_out.content_encoding
+ && r->headers_out.content_encoding->value.len)
+ {
+ return NGX_DECLINED;
+ }
- mc = &r->main->headers_out.charset;
+ if (r->headers_out.content_type.len == 0) {
+ return NGX_DECLINED;
+ }
- if (mc->len == 0) {
- return ngx_http_next_header_filter(r);
- }
+ if (r->headers_out.override_charset
+ && r->headers_out.override_charset->len)
+ {
+ *name = *r->headers_out.override_charset;
- ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_charset_ctx_t));
- if (ctx == NULL) {
- return NGX_ERROR;
- }
+ charset = ngx_http_get_charset(r, name);
- ngx_http_set_ctx(r->main, ctx, ngx_http_charset_filter_module);
+ if (charset != NGX_HTTP_NO_CHARSET) {
+ return charset;
+ }
+
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "unknown charset \"%V\" to override", name);
+
+ return NGX_DECLINED;
+ }
- charset = ngx_http_charset_get_charset(charsets, n, mc);
+ mlcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
+ charset = mlcf->charset;
- ctx->charset = charset;
+ if (charset == NGX_HTTP_CHARSET_OFF) {
+ return NGX_DECLINED;
+ }
- } else {
- charset = ctx->charset;
+ if (r->headers_out.charset.len) {
+ if (mlcf->override_charset == 0) {
+ return NGX_DECLINED;
}
+
+ } else {
+ if (ngx_http_test_content_type(r, &mlcf->types) == NULL) {
+ return NGX_DECLINED;
+ }
+ }
+
+ if (charset < NGX_HTTP_CHARSET_VAR) {
+ mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
+ charsets = mcf->charsets.elts;
+ *name = charsets[charset].name;
+ return charset;
}
- /* source charset */
+ vv = ngx_http_get_indexed_variable(r, charset - NGX_HTTP_CHARSET_VAR);
- if (r->headers_out.charset.len == 0) {
- lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
+ if (vv == NULL || vv->not_found) {
+ return NGX_ERROR;
+ }
- source_charset = lcf->source_charset;
+ name->len = vv->len;
+ name->data = vv->data;
- if (source_charset >= NGX_HTTP_CHARSET_VAR) {
- vv = ngx_http_get_indexed_variable(r,
- source_charset - NGX_HTTP_CHARSET_VAR);
+ return ngx_http_get_charset(r, name);
+}
- if (vv == NULL || vv->not_found) {
- return NGX_ERROR;
- }
- s.len = vv->len;
- s.data = vv->data;
+static ngx_int_t
+ngx_http_main_request_charset(ngx_http_request_t *r, ngx_str_t *src)
+{
+ ngx_int_t charset;
+ ngx_str_t *main_charset;
+ ngx_http_charset_ctx_t *ctx;
- source_charset = ngx_http_charset_get_charset(charsets, n, &s);
- }
+ ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module);
- if (charset != NGX_HTTP_NO_CHARSET) {
- return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset,
- source_charset);
- }
+ if (ctx) {
+ *src = ctx->charset_name;
+ return ctx->charset;
+ }
- if (source_charset == NGX_CONF_UNSET) {
- return ngx_http_next_header_filter(r);
- }
+ main_charset = &r->main->headers_out.charset;
- from = &charsets[source_charset].name;
- to = &r->main->headers_out.charset;
+ if (main_charset->len == 0) {
+ return NGX_DECLINED;
+ }
- goto no_charset_map;
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_charset_ctx_t));
+ if (ctx == NULL) {
+ return NGX_ERROR;
}
- source_charset = ngx_http_charset_get_charset(charsets, n,
- &r->headers_out.charset);
+ ngx_http_set_ctx(r->main, ctx, ngx_http_charset_filter_module);
- if (charset == NGX_HTTP_NO_CHARSET
- || source_charset == NGX_HTTP_NO_CHARSET)
- {
- if (charset != source_charset
- || ngx_strcasecmp(r->main->headers_out.charset.data,
- r->headers_out.charset.data)
- != 0)
- {
- from = &r->headers_out.charset;
- to = (charset == NGX_HTTP_NO_CHARSET) ?
- &r->main->headers_out.charset:
- &charsets[charset].name;
+ charset = ngx_http_get_charset(r, main_charset);
- goto no_charset_map;
- }
+ ctx->charset = charset;
+ ctx->charset_name = *main_charset;
+ *src = *main_charset;
- return ngx_http_next_header_filter(r);
+ return charset;
+}
+
+
+static ngx_int_t
+ngx_http_source_charset(ngx_http_request_t *r, ngx_str_t *name)
+{
+ ngx_int_t charset;
+ ngx_http_charset_t *charsets;
+ ngx_http_variable_value_t *vv;
+ ngx_http_charset_loc_conf_t *lcf;
+ ngx_http_charset_main_conf_t *mcf;
+
+ if (r->headers_out.charset.len) {
+ *name = r->headers_out.charset;
+ return ngx_http_get_charset(r, name);
}
- if (source_charset != charset
- && (charsets[source_charset].tables == NULL
- || charsets[source_charset].tables[charset] == NULL))
- {
- from = &charsets[source_charset].name;
- to = &charsets[charset].name;
+ lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
- goto no_charset_map;
+ charset = lcf->source_charset;
+
+ if (charset == NGX_HTTP_CHARSET_OFF) {
+ name->len = 0;
+ return charset;
}
- r->headers_out.content_type.len = r->headers_out.content_type_len;
+ if (charset < NGX_HTTP_CHARSET_VAR) {
+ mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
+ charsets = mcf->charsets.elts;
+ *name = charsets[charset].name;
+ return charset;
+ }
- return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset,
- source_charset);
+ vv = ngx_http_get_indexed_variable(r, charset - NGX_HTTP_CHARSET_VAR);
-no_charset_map:
+ if (vv == NULL || vv->not_found) {
+ return NGX_ERROR;
+ }
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "no \"charset_map\" between the charsets \"%V\" and \"%V\"",
- from, to);
+ name->len = vv->len;
+ name->data = vv->data;
- return ngx_http_next_header_filter(r);
+ return ngx_http_get_charset(r, name);
}
static ngx_int_t
-ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n,
- ngx_str_t *charset)
+ngx_http_get_charset(ngx_http_request_t *r, ngx_str_t *name)
{
- ngx_uint_t i;
+ ngx_uint_t i, n;
+ ngx_http_charset_t *charset;
+ ngx_http_charset_main_conf_t *mcf;
+
+ mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
+
+ charset = mcf->charsets.elts;
+ n = mcf->charsets.nelts;
for (i = 0; i < n; i++) {
- if (charsets[i].name.len != charset->len) {
+ if (charset[i].name.len != name->len) {
continue;
}
- if (ngx_strncasecmp(charsets[i].name.data, charset->data, charset->len)
- == 0)
- {
+ if (ngx_strncasecmp(charset[i].name.data, name->data, name->len) == 0) {
return i;
}
}
@@ -416,11 +482,12 @@ ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n,
}
-static ngx_int_t
-ngx_http_charset_set_charset(ngx_http_request_t *r,
- ngx_http_charset_t *charsets, ngx_int_t charset, ngx_int_t source_charset)
+static ngx_inline void
+ngx_http_set_charset(ngx_http_request_t *r, ngx_str_t *charset)
{
- ngx_http_charset_ctx_t *ctx;
+ if (r != r->main) {
+ return;
+ }
if (r->headers_out.status == NGX_HTTP_MOVED_PERMANENTLY
|| r->headers_out.status == NGX_HTTP_MOVED_TEMPORARILY)
@@ -431,16 +498,18 @@ ngx_http_charset_set_charset(ngx_http_request_t *r,
*/
r->headers_out.charset.len = 0;
-
- return ngx_http_next_header_filter(r);
+ return;
}
- r->headers_out.charset = charsets[charset].name;
- r->utf8 = charsets[charset].utf8;
+ r->headers_out.charset = *charset;
+}
- if (source_charset == NGX_CONF_UNSET || source_charset == charset) {
- return ngx_http_next_header_filter(r);
- }
+
+static ngx_int_t
+ngx_http_charset_ctx(ngx_http_request_t *r, ngx_http_charset_t *charsets,
+ ngx_int_t charset, ngx_int_t source_charset)
+{
+ ngx_http_charset_ctx_t *ctx;
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_charset_ctx_t));
if (ctx == NULL) {
@@ -451,6 +520,7 @@ ngx_http_charset_set_charset(ngx_http_request_t *r,
ctx->table = charsets[source_charset].tables[charset];
ctx->charset = charset;
+ ctx->charset_name = charsets[charset].name;
ctx->length = charsets[charset].length;
ctx->from_utf8 = charsets[source_charset].utf8;
ctx->to_utf8 = charsets[charset].utf8;
@@ -1338,7 +1408,7 @@ ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
if (cmd->offset == offsetof(ngx_http_charset_loc_conf_t, charset)
&& ngx_strcmp(value[1].data, "off") == 0)
{
- *cp = NGX_HTTP_NO_CHARSET;
+ *cp = NGX_HTTP_CHARSET_OFF;
return NGX_CONF_OK;
}
@@ -1418,27 +1488,27 @@ ngx_http_charset_create_main_conf(ngx_conf_t *cf)
mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_main_conf_t));
if (mcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&mcf->tables, cf->pool, 1,
sizeof(ngx_http_charset_tables_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&mcf->recodes, cf->pool, 2,
sizeof(ngx_http_charset_recode_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
return mcf;
@@ -1452,7 +1522,7 @@ ngx_http_charset_create_loc_conf(ngx_conf_t *cf)
lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_loc_conf_t));
if (lcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
@@ -1489,14 +1559,12 @@ ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
}
ngx_conf_merge_value(conf->override_charset, prev->override_charset, 0);
- ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_NO_CHARSET);
-
- if (conf->source_charset == NGX_CONF_UNSET) {
- conf->source_charset = prev->source_charset;
- }
+ ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_CHARSET_OFF);
+ ngx_conf_merge_value(conf->source_charset, prev->source_charset,
+ NGX_HTTP_CHARSET_OFF);
- if (conf->charset == NGX_HTTP_NO_CHARSET
- || conf->source_charset == NGX_CONF_UNSET
+ if (conf->charset == NGX_HTTP_CHARSET_OFF
+ || conf->source_charset == NGX_HTTP_CHARSET_OFF
|| conf->charset == conf->source_charset)
{
return NGX_CONF_OK;
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index 84a7672a4..7f53d5416 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -1154,7 +1154,7 @@ ngx_http_dav_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_dav_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 83178dba6..2373d7cdf 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1833,7 +1833,7 @@ ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
@@ -1911,7 +1911,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
if (conf->upstream.store != 0) {
ngx_conf_merge_value(conf->upstream.store,
- prev->upstream.store, 0);
+ prev->upstream.store, 0);
if (conf->upstream.store_lengths == NULL) {
conf->upstream.store_lengths = prev->upstream.store_lengths;
@@ -2541,20 +2541,31 @@ ngx_http_fastcgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_str_t *value;
ngx_http_script_compile_t sc;
- if (flcf->upstream.store != NGX_CONF_UNSET || flcf->upstream.store_lengths)
+ if (flcf->upstream.store != NGX_CONF_UNSET
+ || flcf->upstream.store_lengths)
{
return "is duplicate";
}
value = cf->args->elts;
- if (ngx_strcmp(value[1].data, "on") == 0) {
- flcf->upstream.store = 1;
+ if (ngx_strcmp(value[1].data, "off") == 0) {
+ flcf->upstream.store = 0;
return NGX_CONF_OK;
}
- if (ngx_strcmp(value[1].data, "off") == 0) {
- flcf->upstream.store = 0;
+#if (NGX_HTTP_CACHE)
+
+ if (flcf->upstream.cache != NGX_CONF_UNSET_PTR
+ && flcf->upstream.cache != NULL)
+ {
+ return "is incompatible with \"fastcgi_cache\"";
+ }
+
+#endif
+
+ if (ngx_strcmp(value[1].data, "on") == 0) {
+ flcf->upstream.store = 1;
return NGX_CONF_OK;
}
@@ -2599,6 +2610,10 @@ ngx_http_fastcgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}
+ if (flcf->upstream.store > 0 || flcf->upstream.store_lengths) {
+ return "is incompatible with \"fastcgi_store\"";
+ }
+
flcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0,
&ngx_http_fastcgi_module);
if (flcf->upstream.cache == NULL) {
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
index 7c7ca0a6c..62b430b71 100644
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -1069,7 +1069,7 @@ ngx_http_gzip_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_gzip_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_gzip_static_module.c b/src/http/modules/ngx_http_gzip_static_module.c
index 22e806ac3..19e412841 100644
--- a/src/http/modules/ngx_http_gzip_static_module.c
+++ b/src/http/modules/ngx_http_gzip_static_module.c
@@ -251,7 +251,7 @@ ngx_http_gzip_static_create_conf(ngx_conf_t *cf)
conf = ngx_palloc(cf->pool, sizeof(ngx_http_gzip_static_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
conf->enable = NGX_CONF_UNSET;
diff --git a/src/http/modules/ngx_http_headers_filter_module.c b/src/http/modules/ngx_http_headers_filter_module.c
index 13cef0bea..3b5ebd68f 100644
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -421,7 +421,7 @@ ngx_http_headers_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_headers_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
index 293a61fc3..b0e5fed6b 100644
--- a/src/http/modules/ngx_http_image_filter_module.c
+++ b/src/http/modules/ngx_http_image_filter_module.c
@@ -947,7 +947,7 @@ ngx_http_image_filter_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_image_filter_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
conf->filter = NGX_CONF_UNSET_UINT;
diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c
index f88e599a7..d94fc118c 100644
--- a/src/http/modules/ngx_http_index_module.c
+++ b/src/http/modules/ngx_http_index_module.c
@@ -366,7 +366,7 @@ ngx_http_index_create_loc_conf(ngx_conf_t *cf)
conf = ngx_palloc(cf->pool, sizeof(ngx_http_index_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
conf->indices = NULL;
diff --git a/src/http/modules/ngx_http_limit_req_module.c b/src/http/modules/ngx_http_limit_req_module.c
index 3d20b295d..2a07c74e5 100644
--- a/src/http/modules/ngx_http_limit_req_module.c
+++ b/src/http/modules/ngx_http_limit_req_module.c
@@ -522,7 +522,7 @@ ngx_http_limit_req_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_limit_req_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_limit_zone_module.c b/src/http/modules/ngx_http_limit_zone_module.c
index e11e0815b..95f07c6b5 100644
--- a/src/http/modules/ngx_http_limit_zone_module.c
+++ b/src/http/modules/ngx_http_limit_zone_module.c
@@ -381,7 +381,7 @@ ngx_http_limit_zone_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_limit_zone_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
index efe720bf5..170e3a264 100644
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -714,18 +714,18 @@ ngx_http_log_create_main_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&conf->formats, cf->pool, 4, sizeof(ngx_http_log_fmt_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
fmt = ngx_array_push(&conf->formats);
if (fmt == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
fmt->name.len = sizeof("combined") - 1;
@@ -735,7 +735,7 @@ ngx_http_log_create_main_conf(ngx_conf_t *cf)
fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t));
if (fmt->ops == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
return conf;
@@ -749,7 +749,7 @@ ngx_http_log_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
conf->open_file_cache = NGX_CONF_UNSET_PTR;
diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c
index d0eb02c64..1f7786c3c 100644
--- a/src/http/modules/ngx_http_map_module.c
+++ b/src/http/modules/ngx_http_map_module.c
@@ -160,7 +160,7 @@ ngx_http_map_create_conf(ngx_conf_t *cf)
mcf = ngx_palloc(cf->pool, sizeof(ngx_http_map_conf_t));
if (mcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
mcf->hash_max_size = NGX_CONF_UNSET_UINT;
diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
index f68be1e44..e613a2079 100644
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -513,7 +513,7 @@ ngx_http_memcached_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_memcached_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index 484694d14..6d7350176 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1883,7 +1883,7 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
@@ -1973,7 +1973,7 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
if (conf->upstream.store != 0) {
ngx_conf_merge_value(conf->upstream.store,
- prev->upstream.store, 0);
+ prev->upstream.store, 0);
if (conf->upstream.store_lengths == NULL) {
conf->upstream.store_lengths = prev->upstream.store_lengths;
@@ -2809,20 +2809,31 @@ ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_str_t *value;
ngx_http_script_compile_t sc;
- if (plcf->upstream.store != NGX_CONF_UNSET || plcf->upstream.store_lengths)
+ if (plcf->upstream.store != NGX_CONF_UNSET
+ || plcf->upstream.store_lengths)
{
return "is duplicate";
}
value = cf->args->elts;
- if (ngx_strcmp(value[1].data, "on") == 0) {
- plcf->upstream.store = 1;
+ if (ngx_strcmp(value[1].data, "off") == 0) {
+ plcf->upstream.store = 0;
return NGX_CONF_OK;
}
- if (ngx_strcmp(value[1].data, "off") == 0) {
- plcf->upstream.store = 0;
+#if (NGX_HTTP_CACHE)
+
+ if (plcf->upstream.cache != NGX_CONF_UNSET_PTR
+ && plcf->upstream.cache != NULL)
+ {
+ return "is incompatible with \"proxy_cache\"";
+ }
+
+#endif
+
+ if (ngx_strcmp(value[1].data, "on") == 0) {
+ plcf->upstream.store = 1;
return NGX_CONF_OK;
}
@@ -2867,6 +2878,10 @@ ngx_http_proxy_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}
+ if (plcf->upstream.store > 0 || plcf->upstream.store_lengths) {
+ return "is incompatible with \"proxy_store\"";
+ }
+
plcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0,
&ngx_http_proxy_module);
if (plcf->upstream.cache == NULL) {
diff --git a/src/http/modules/ngx_http_random_index_module.c b/src/http/modules/ngx_http_random_index_module.c
index 7ddb819af..bb5544ae6 100644
--- a/src/http/modules/ngx_http_random_index_module.c
+++ b/src/http/modules/ngx_http_random_index_module.c
@@ -280,7 +280,7 @@ ngx_http_random_index_create_loc_conf(ngx_conf_t *cf)
conf = ngx_palloc(cf->pool, sizeof(ngx_http_random_index_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
conf->enable = NGX_CONF_UNSET;
diff --git a/src/http/modules/ngx_http_realip_module.c b/src/http/modules/ngx_http_realip_module.c
index b069a1eba..3b2cce679 100644
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -360,7 +360,7 @@ ngx_http_realip_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_realip_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_referer_module.c b/src/http/modules/ngx_http_referer_module.c
index 05828997b..658f4a19c 100644
--- a/src/http/modules/ngx_http_referer_module.c
+++ b/src/http/modules/ngx_http_referer_module.c
@@ -221,7 +221,7 @@ ngx_http_referer_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_referer_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
#if (NGX_PCRE)
diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c
index a84844356..840c05330 100644
--- a/src/http/modules/ngx_http_rewrite_module.c
+++ b/src/http/modules/ngx_http_rewrite_module.c
@@ -220,7 +220,7 @@ ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_rewrite_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
conf->stack_size = NGX_CONF_UNSET_UINT;
diff --git a/src/http/modules/ngx_http_secure_link_module.c b/src/http/modules/ngx_http_secure_link_module.c
index 049a45c3e..2f9351d91 100644
--- a/src/http/modules/ngx_http_secure_link_module.c
+++ b/src/http/modules/ngx_http_secure_link_module.c
@@ -152,7 +152,7 @@ ngx_http_secure_link_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_secure_link_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c
index d27d854a8..97b58fa0a 100644
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -2689,14 +2689,14 @@ ngx_http_ssi_create_main_conf(ngx_conf_t *cf)
smcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_main_conf_t));
if (smcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
smcf->commands.pool = cf->pool;
smcf->commands.temp_pool = cf->temp_pool;
if (ngx_hash_keys_array_init(&smcf->commands, NGX_HASH_SMALL) != NGX_OK) {
- return NGX_CONF_ERROR;
+ return NULL;
}
return smcf;
@@ -2736,7 +2736,7 @@ ngx_http_ssi_create_loc_conf(ngx_conf_t *cf)
slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_loc_conf_t));
if (slcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c
index 3bf52a2c7..c0fd6fdda 100644
--- a/src/http/modules/ngx_http_ssl_module.c
+++ b/src/http/modules/ngx_http_ssl_module.c
@@ -302,7 +302,7 @@ ngx_http_ssl_create_srv_conf(ngx_conf_t *cf)
sscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_srv_conf_t));
if (sscf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_sub_filter_module.c b/src/http/modules/ngx_http_sub_filter_module.c
index 34f32946d..9f078819d 100644
--- a/src/http/modules/ngx_http_sub_filter_module.c
+++ b/src/http/modules/ngx_http_sub_filter_module.c
@@ -638,7 +638,7 @@ ngx_http_sub_create_conf(ngx_conf_t *cf)
slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_sub_loc_conf_t));
if (slcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_userid_filter_module.c b/src/http/modules/ngx_http_userid_filter_module.c
index 3462f649c..9997274a6 100644
--- a/src/http/modules/ngx_http_userid_filter_module.c
+++ b/src/http/modules/ngx_http_userid_filter_module.c
@@ -570,7 +570,7 @@ ngx_http_userid_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/ngx_http_xslt_filter_module.c b/src/http/modules/ngx_http_xslt_filter_module.c
index 9703b50ae..87828f962 100644
--- a/src/http/modules/ngx_http_xslt_filter_module.c
+++ b/src/http/modules/ngx_http_xslt_filter_module.c
@@ -280,7 +280,7 @@ ngx_http_xslt_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
return ngx_http_xslt_send(r, ctx, NULL);
}
- if (cl->buf->last_buf) {
+ if (cl->buf->last_buf || cl->buf->last_in_chain) {
ctx->doc = ctx->ctxt->myDoc;
@@ -427,8 +427,8 @@ ngx_http_xslt_add_chunk(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx,
ctx->request = r;
}
- err = xmlParseChunk(ctx->ctxt, (char *) b->pos,
- (int) (b->last - b->pos), b->last_buf);
+ err = xmlParseChunk(ctx->ctxt, (char *) b->pos, (int) (b->last - b->pos),
+ (b->last_buf) || (b->last_in_chain));
if (err == 0) {
b->pos = b->last;
@@ -812,7 +812,6 @@ ngx_http_xslt_apply_stylesheet(ngx_http_request_t *r,
b->pos = buf;
b->last = buf + len;
b->memory = 1;
- b->last_buf = 1;
if (encoding) {
r->headers_out.charset.len = ngx_strlen(encoding);
@@ -823,6 +822,8 @@ ngx_http_xslt_apply_stylesheet(ngx_http_request_t *r,
return b;
}
+ b->last_buf = 1;
+
if (type) {
len = ngx_strlen(type);
@@ -1168,7 +1169,7 @@ ngx_http_xslt_filter_create_main_conf(ngx_conf_t *cf)
conf = ngx_palloc(cf->pool, sizeof(ngx_http_xslt_filter_main_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&conf->dtd_files, cf->pool, 1,
@@ -1196,7 +1197,7 @@ ngx_http_xslt_filter_create_conf(ngx_conf_t *cf)
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_xslt_filter_loc_conf_t));
if (conf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm
index d92ec327b..5901d38a9 100644
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -47,7 +47,7 @@ our @EXPORT = qw(
HTTP_INSUFFICIENT_STORAGE
);
-our $VERSION = '0.7.59';
+our $VERSION = '0.8.0';
require XSLoader;
XSLoader::load('nginx', $VERSION);
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index e22428a78..4409e8fa7 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -784,7 +784,7 @@ ngx_http_perl_create_main_conf(ngx_conf_t *cf)
pmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_main_conf_t));
if (pmcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&pmcf->requires, cf->pool, 1, sizeof(u_char *))
@@ -869,7 +869,7 @@ ngx_http_perl_create_loc_conf(ngx_conf_t *cf)
plcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_loc_conf_t));
if (plcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 966cbc270..3d2ccd083 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -433,6 +433,14 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_loc_conf_t, limit_rate),
NULL },
+ { ngx_string("limit_rate_after"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+ |NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, limit_rate_after),
+ NULL },
+
{ ngx_string("keepalive_timeout"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
ngx_http_core_keepalive,
@@ -440,6 +448,13 @@ static ngx_command_t ngx_http_core_commands[] = {
0,
NULL },
+ { ngx_string("keepalive_requests"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, keepalive_requests),
+ NULL },
+
{ ngx_string("satisfy"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_enum_slot,
@@ -1326,8 +1341,13 @@ ngx_http_update_location_config(ngx_http_request_t *r)
r->request_body_in_single_buf = clcf->client_body_in_single_buffer;
- if (r->keepalive && clcf->keepalive_timeout == 0) {
- r->keepalive = 0;
+ if (r->keepalive) {
+ if (clcf->keepalive_timeout == 0) {
+ r->keepalive = 0;
+
+ } else if (r->connection->requests >= clcf->keepalive_requests) {
+ r->keepalive = 0;
+ }
}
if (!clcf->tcp_nopush) {
@@ -2683,14 +2703,14 @@ ngx_http_core_create_main_conf(ngx_conf_t *cf)
cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t));
if (cmcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&cmcf->servers, cf->pool, 4,
sizeof(ngx_http_core_srv_conf_t *))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
cmcf->server_names_hash_max_size = NGX_CONF_UNSET_UINT;
@@ -2742,7 +2762,7 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
cscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t));
if (cscf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
@@ -2755,14 +2775,14 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
sizeof(ngx_http_listen_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&cscf->server_names, cf->temp_pool, 4,
sizeof(ngx_http_server_name_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
cscf->connection_pool_size = NGX_CONF_UNSET_SIZE;
@@ -2873,7 +2893,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t));
if (lcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*
@@ -2912,8 +2932,10 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
lcf->send_lowat = NGX_CONF_UNSET_SIZE;
lcf->postpone_output = NGX_CONF_UNSET_SIZE;
lcf->limit_rate = NGX_CONF_UNSET_SIZE;
+ lcf->limit_rate_after = NGX_CONF_UNSET_SIZE;
lcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
lcf->keepalive_header = NGX_CONF_UNSET;
+ lcf->keepalive_requests = NGX_CONF_UNSET_UINT;
lcf->lingering_time = NGX_CONF_UNSET_MSEC;
lcf->lingering_timeout = NGX_CONF_UNSET_MSEC;
lcf->resolver_timeout = NGX_CONF_UNSET_MSEC;
@@ -3110,10 +3132,14 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,
1460);
ngx_conf_merge_size_value(conf->limit_rate, prev->limit_rate, 0);
+ ngx_conf_merge_size_value(conf->limit_rate_after, prev->limit_rate_after,
+ 0);
ngx_conf_merge_msec_value(conf->keepalive_timeout,
prev->keepalive_timeout, 75000);
ngx_conf_merge_sec_value(conf->keepalive_header,
prev->keepalive_header, 0);
+ ngx_conf_merge_uint_value(conf->keepalive_requests,
+ prev->keepalive_requests, 100);
ngx_conf_merge_msec_value(conf->lingering_time,
prev->lingering_time, 30000);
ngx_conf_merge_msec_value(conf->lingering_timeout,
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index dfc07facc..e7bffbfa7 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -324,6 +324,7 @@ struct ngx_http_core_loc_conf_s {
size_t send_lowat; /* send_lowat */
size_t postpone_output; /* postpone_output */
size_t limit_rate; /* limit_rate */
+ size_t limit_rate_after; /* limit_rate_after */
size_t sendfile_max_chunk; /* sendfile_max_chunk */
ngx_msec_t client_body_timeout; /* client_body_timeout */
@@ -337,6 +338,7 @@ struct ngx_http_core_loc_conf_s {
time_t keepalive_header; /* keepalive_timeout */
+ ngx_uint_t keepalive_requests; /* keepalive_requests */
ngx_uint_t satisfy; /* satisfy */
ngx_uint_t if_modified_since; /* if_modified_since */
ngx_uint_t client_body_in_file_only; /* client_body_in_file_only */
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index c9c6db729..be5c91cbf 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -259,6 +259,8 @@ ngx_http_init_request(ngx_event_t *rev)
return;
}
+ c->requests++;
+
hc = c->data;
if (hc == NULL) {
@@ -449,13 +451,15 @@ ngx_http_init_request(ngx_event_t *rev)
sizeof(ngx_table_elt_t))
!= NGX_OK)
{
- ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ ngx_destroy_pool(r->pool);
+ ngx_http_close_connection(c);
return;
}
r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
if (r->ctx == NULL) {
- ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ ngx_destroy_pool(r->pool);
+ ngx_http_close_connection(c);
return;
}
@@ -464,7 +468,8 @@ ngx_http_init_request(ngx_event_t *rev)
r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts
* sizeof(ngx_http_variable_value_t));
if (r->variables == NULL) {
- ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ ngx_destroy_pool(r->pool);
+ ngx_http_close_connection(c);
return;
}
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 97ffbbf21..fd830b2a5 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -488,7 +488,6 @@ struct ngx_http_request_s {
unsigned root_tested:1;
unsigned done:1;
unsigned logged:1;
- unsigned utf8:1;
unsigned buffered:4;
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index b8e998abb..dbe6c34bd 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -561,7 +561,7 @@ ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code)
new = ngx_array_push_n(codes, size);
if (new == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
if (code) {
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index eb839e11b..1d9ccb8b0 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -4182,7 +4182,7 @@ ngx_http_upstream_create_main_conf(ngx_conf_t *cf)
sizeof(ngx_http_upstream_srv_conf_t *))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
return umcf;
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c
index 4381a4a57..46351349c 100644
--- a/src/http/ngx_http_write_filter_module.c
+++ b/src/http/ngx_http_write_filter_module.c
@@ -46,7 +46,7 @@ ngx_module_t ngx_http_write_filter_module = {
ngx_int_t
ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
- off_t size, sent, limit;
+ off_t size, sent, nsent, limit;
ngx_uint_t last, flush;
ngx_msec_t delay;
ngx_chain_t *cl, *ln, **ll, *chain;
@@ -210,7 +210,8 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
if (r->limit_rate) {
- limit = r->limit_rate * (ngx_time() - r->start_sec + 1) - c->sent;
+ limit = r->limit_rate * (ngx_time() - r->start_sec + 1)
+ - (c->sent - clcf->limit_rate_after);
if (limit <= 0) {
c->write->delayed = 1;
@@ -245,7 +246,23 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
if (r->limit_rate) {
- delay = (ngx_msec_t) ((c->sent - sent) * 1000 / r->limit_rate + 1);
+
+ nsent = c->sent;
+
+ if (clcf->limit_rate_after) {
+
+ sent -= clcf->limit_rate_after;
+ if (sent < 0) {
+ sent = 0;
+ }
+
+ nsent -= clcf->limit_rate_after;
+ if (nsent < 0) {
+ nsent = 0;
+ }
+ }
+
+ delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate + 1);
if (delay > 0) {
c->write->delayed = 1;
diff --git a/src/mail/ngx_mail_auth_http_module.c b/src/mail/ngx_mail_auth_http_module.c
index f7ad3085b..acd06656f 100644
--- a/src/mail/ngx_mail_auth_http_module.c
+++ b/src/mail/ngx_mail_auth_http_module.c
@@ -1302,7 +1302,7 @@ ngx_mail_auth_http_create_conf(ngx_conf_t *cf)
ahcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_auth_http_conf_t));
if (ahcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
ahcf->timeout = NGX_CONF_UNSET_MSEC;
diff --git a/src/mail/ngx_mail_core_module.c b/src/mail/ngx_mail_core_module.c
index d0addb059..bd2c916d5 100644
--- a/src/mail/ngx_mail_core_module.c
+++ b/src/mail/ngx_mail_core_module.c
@@ -120,20 +120,20 @@ ngx_mail_core_create_main_conf(ngx_conf_t *cf)
cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_main_conf_t));
if (cmcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&cmcf->servers, cf->pool, 4,
sizeof(ngx_mail_core_srv_conf_t *))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_mail_listen_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NULL;
}
return cmcf;
diff --git a/src/mail/ngx_mail_proxy_module.c b/src/mail/ngx_mail_proxy_module.c
index 193df8ada..b408ed7d3 100644
--- a/src/mail/ngx_mail_proxy_module.c
+++ b/src/mail/ngx_mail_proxy_module.c
@@ -1061,7 +1061,7 @@ ngx_mail_proxy_create_conf(ngx_conf_t *cf)
pcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_proxy_conf_t));
if (pcf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
pcf->enable = NGX_CONF_UNSET;
diff --git a/src/mail/ngx_mail_ssl_module.c b/src/mail/ngx_mail_ssl_module.c
index 4e2bda5f2..1fcdb7559 100644
--- a/src/mail/ngx_mail_ssl_module.c
+++ b/src/mail/ngx_mail_ssl_module.c
@@ -166,7 +166,7 @@ ngx_mail_ssl_create_conf(ngx_conf_t *cf)
scf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_ssl_conf_t));
if (scf == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
/*