changeset 675:e924670896ab release-0.3.59

nginx-0.3.59-RELEASE import *) Feature: now is possible to do several redirection using the "error_page" directive. *) Bugfix: the "dav_access" directive did not support three parameters. *) Bugfix: the "error_page" directive did not changes the "Content-Type" header line after the "X-Accel-Redirect" was used; the bug had appeared in 0.3.58.
author Igor Sysoev <igor@sysoev.ru>
date Wed, 16 Aug 2006 13:09:33 +0000
parents c4b2ba082d99
children c4d2b8200883
files auto/lib/md5/makefile.msvc auto/lib/sha1/makefile.msvc docs/xml/nginx/changes.xml src/core/nginx.h src/http/modules/ngx_http_dav_module.c src/http/modules/ngx_http_memcached_module.c src/http/ngx_http.h src/http/ngx_http_core_module.c src/http/ngx_http_request.c src/http/ngx_http_request.h src/http/ngx_http_special_response.c src/http/ngx_http_upstream.c src/http/ngx_http_upstream.h
diffstat 13 files changed, 62 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/auto/lib/md5/makefile.msvc
+++ b/auto/lib/md5/makefile.msvc
@@ -4,16 +4,16 @@
 
 CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN
 
-!if "$(MD5_ASM)" == "YES"
+!IF "$(MD5_ASM)" == "YES"
 
 md5.lib:
 	cl -c $(CFLAGS) -D MD5_ASM md5_dgst.c
 	link -lib -out:md5.lib md5_dgst.obj asm/m-win32.obj
 
-!else
+!ELSE
 
 md5.lib:
 	cl -c $(CFLAGS) md5_dgst.c
 	link -lib -out:md5.lib md5_dgst.obj
 
-!endif
+!ENDIF
--- a/auto/lib/sha1/makefile.msvc
+++ b/auto/lib/sha1/makefile.msvc
@@ -4,16 +4,16 @@
 
 CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN
 
-!if "$(SHA1_ASM)" == "YES"
+!IF "$(SHA1_ASM)" == "YES"
 
 sha1.lib:
 	cl -c $(CFLAGS) -D SHA1_ASM sha1dgst.c
 	link -lib -out:sha1.lib sha1dgst.obj asm/s-win32.obj
 
-!else
+!ELSE
 
 sha1.lib:
 	cl -c $(CFLAGS) sha1dgst.c
 	link -lib -out:sha1.lib sha1dgst.obj
 
-!endif
+!ENDIF
--- a/docs/xml/nginx/changes.xml
+++ b/docs/xml/nginx/changes.xml
@@ -9,6 +9,42 @@
 <title lang="en">nginx changelog</title>
 
 
+<changes ver="0.3.59" date="16.08.2006">
+
+<change type="feature">
+<para lang="ru">
+теперь можно делать несколько перенаправлений через директиву error_page.
+</para>
+<para lang="en">
+now is possible to do several redirection using the "error_page" directive.
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+директива dav_access не поддерживала три параметра.
+</para>
+<para lang="en">
+the "dav_access" directive did not support three parameters.
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+директива error_page не изменяла строку "Content-Type"
+после перенаправления с помощью "X-Accel-Redirect";
+ошибка появилась в 0.3.58.
+</para>
+<para lang="en">
+the "error_page" directive did not changes the "Content-Type" header line
+after the "X-Accel-Redirect" was used;
+bug appeared in 0.3.58.
+</para>
+</change>
+
+</changes>
+
+
 <changes ver="0.3.58" date="14.08.2006">
 
 <change type="feature">
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.3.58"
+#define NGINX_VER          "nginx/0.3.59"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_OLDPID_EXT     ".oldbin"
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -57,7 +57,7 @@ static ngx_command_t  ngx_http_dav_comma
       NULL },
 
     { ngx_string("dav_access"),
-      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
       ngx_http_dav_access,
       NGX_HTTP_LOC_CONF_OFFSET,
       0,
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -526,7 +526,7 @@ ngx_http_memcached_create_loc_conf(ngx_c
     conf->upstream.max_temp_file_size = 0;
     conf->upstream.temp_file_write_size = 0;
     conf->upstream.intercept_errors = 1;
-    conf->upstream.redirect_404 = 1;
+    conf->upstream.intercept_404 = 1;
     conf->upstream.pass_request_headers = 0;
     conf->upstream.pass_request_body = 0;
 
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -53,12 +53,8 @@ struct ngx_http_log_ctx_s {
 };
 
 
-#define ngx_http_get_module_ctx(r, module)     (r)->ctx[module.ctx_index]
-#define ngx_http_get_module_err_ctx(r, module)                                \
-    ((r)->err_ctx ? (r)->err_ctx[module.ctx_index] : (r)->ctx[module.ctx_index])
-
-#define ngx_http_set_ctx(r, c, module)         r->ctx[module.ctx_index] = c;
-#define ngx_http_delete_ctx(r, module)         r->ctx[module.ctx_index] = NULL;
+#define ngx_http_get_module_ctx(r, module)  (r)->ctx[module.ctx_index]
+#define ngx_http_set_ctx(r, c, module)      r->ctx[module.ctx_index] = c;
 
 
 void ngx_http_init_connection(ngx_connection_t *c);
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -464,7 +464,7 @@ ngx_http_handler(ngx_http_request_t *r)
 
     r->connection->unexpected_eof = 0;
 
-    if (r->err_ctx == NULL) {
+    if (!r->internal) {
         switch (r->headers_in.connection_type) {
         case 0:
             if (r->http_version > NGX_HTTP_VERSION_10) {
@@ -1341,21 +1341,8 @@ ngx_http_internal_redirect(ngx_http_requ
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    if (r->err_ctx) {
-
-        /* allocate the new module's contexts */
-
-        r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
-        if (r->ctx == NULL) {
-            return NGX_HTTP_INTERNAL_SERVER_ERROR;
-        }
-
-    } else {
-
-        /* clear the modules contexts */
-
-        ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
-    }
+    /* clear the modules contexts */
+    ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
 
     cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
     r->loc_conf = cscf->ctx->loc_conf;
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -424,6 +424,9 @@ ngx_http_init_request(ngx_event_t *rev)
     r->headers_out.content_length_n = -1;
     r->headers_out.last_modified_time = -1;
 
+    r->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1;
+    r->subrequests = NGX_HTTP_MAX_SUBREQUESTS + 1;
+
     r->http_state = NGX_HTTP_READING_REQUEST_STATE;
 
     ctx = c->log->data;
@@ -667,9 +670,6 @@ ngx_http_process_request_line(ngx_event_
                 c->write->handler = ngx_http_request_handler;
                 r->read_event_handler = ngx_http_block_read;
 
-                r->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1;
-                r->subrequests = NGX_HTTP_MAX_SUBREQUESTS + 1;
-
                 ngx_http_handler(r);
 
                 return;
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -368,7 +368,6 @@ struct ngx_http_request_s {
 
     off_t                             request_length;
 
-    void                            **err_ctx;
     ngx_uint_t                        err_status;
 
     ngx_http_connection_t            *http_connection;
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -336,9 +336,11 @@ ngx_http_special_response_handler(ngx_ht
         }
     }
 
+    r->headers_out.content_type.len = 0;
+
     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
-    if (r->err_ctx == NULL && clcf->error_pages) {
+    if (clcf->error_pages) {
 
         err_page = clcf->error_pages->elts;
 
@@ -346,7 +348,6 @@ ngx_http_special_response_handler(ngx_ht
 
             if (err_page[i].status == error) {
                 r->err_status = err_page[i].overwrite;
-                r->err_ctx = r->ctx;
 
                 r->method = NGX_HTTP_GET;
 
@@ -370,8 +371,9 @@ ngx_http_special_response_handler(ngx_ht
                                         ngx_list_push(&r->headers_out.headers);
 
                 if (r->headers_out.location) {
+                    error = NGX_HTTP_MOVED_TEMPORARILY;
+
                     r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
-                    error = NGX_HTTP_MOVED_TEMPORARILY;
 
                     r->headers_out.location->hash = 1;
                     r->headers_out.location->key.len = sizeof("Location") - 1;
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1093,17 +1093,15 @@ ngx_http_upstream_process_header(ngx_eve
             return;
         }
 
-        if (u->conf->redirect_404) {
-            rc = (r->err_ctx == NULL) ? 404 : 204;
-            ngx_http_upstream_finalize_request(r, u, rc);
+        if (u->conf->intercept_404) {
+            ngx_http_upstream_finalize_request(r, u, NGX_HTTP_NOT_FOUND);
             return;
         }
     }
 
 
     if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST
-        && u->conf->intercept_errors
-        && r->err_ctx == NULL)
+        && u->conf->intercept_errors)
     {
         clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -103,7 +103,7 @@ typedef struct {
     ngx_str_t                       location;
     ngx_str_t                       url;  /* used in proxy_rewrite_location */
 
-    unsigned                        redirect_404:1;
+    unsigned                        intercept_404:1;
     unsigned                        change_buffering:1;
 
 #if (NGX_HTTP_SSL)