changeset 202:ca5f86d94316 NGINX_0_3_48

nginx 0.3.48 *) Change: now the ngx_http_charset_module works for subrequests, if the response has no "Content-Type" header line. *) Bugfix: if the "proxy_pass" directive has no URI part, then the "proxy_redirect default" directive add the unnecessary slash in start of the rewritten redirect. *) Bugfix: the internal redirect always transform client's HTTP method to GET, now the transformation is made for the "X-Accel-Redirect" redirects only and if the method is not HEAD; bug appeared in 0.3.42. *) Bugfix: the ngx_http_perl_module could not be built, if the perl was built with the threads support; bug appeared in 0.3.46.
author Igor Sysoev <http://sysoev.ru>
date Mon, 29 May 2006 00:00:00 +0400
parents 958c1992c173
children 14db5e3fc915
files CHANGES CHANGES.ru auto/cc/msvc auto/lib/conf auto/lib/make auto/lib/md5/makefile.bcc auto/lib/md5/makefile.msvc auto/lib/sha1/conf auto/lib/sha1/make auto/lib/sha1/makefile.bcc auto/lib/sha1/makefile.msvc auto/lib/sha1/makefile.owc auto/options auto/summary src/core/nginx.h src/http/modules/ngx_http_charset_filter_module.c src/http/modules/ngx_http_proxy_module.c src/http/modules/perl/ngx_http_perl_module.c src/http/ngx_http_core_module.c src/http/ngx_http_request.c src/http/ngx_http_script.c src/http/ngx_http_upstream.c
diffstat 22 files changed, 384 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Tue May 23 00:00:00 2006 +0400
+++ b/CHANGES	Mon May 29 00:00:00 2006 +0400
@@ -1,4 +1,21 @@
 
+Changes with nginx 0.3.48                                        29 May 2006
+
+    *) Change: now the ngx_http_charset_module works for subrequests, if 
+       the response has no "Content-Type" header line.
+
+    *) Bugfix: if the "proxy_pass" directive has no URI part, then the 
+       "proxy_redirect default" directive add the unnecessary slash in 
+       start of the rewritten redirect.
+
+    *) Bugfix: the internal redirect always transform client's HTTP method 
+       to GET, now the transformation is made for the "X-Accel-Redirect" 
+       redirects only and if the method is not HEAD; bug appeared in 0.3.42.
+
+    *) Bugfix: the ngx_http_perl_module could not be built, if the perl was 
+       built with the threads support; bug appeared in 0.3.46.
+
+
 Changes with nginx 0.3.47                                        23 May 2006
 
     *) Feature: the "upstream" directive.
--- a/CHANGES.ru	Tue May 23 00:00:00 2006 +0400
+++ b/CHANGES.ru	Mon May 29 00:00:00 2006 +0400
@@ -1,4 +1,22 @@
 
+Изменения в nginx 0.3.48                                          29.05.2006
+
+    *) Изменение: теперь модуль ngx_http_charset_module работает для 
+       подзапросов, в ответах которых нет строки заголовка "Content-Type".
+
+    *) Исправление: если в директиве proxy_pass не было URI, то директива 
+       "proxy_redirect default" добавляла в переписанный редирект в начало 
+       лишний слэш.
+
+    *) Исправление: внутренний редирект всегда превращал любой HTTP-метод в 
+       GET, теперь это делается только для редиректов, выполняемых с 
+       помощью X-Accel-Redirect, и у которых метод не равен HEAD; ошибка 
+       появилась в 0.3.42.
+
+    *) Исправление: модуль ngx_http_perl_module не собирался, если перл был 
+       с поддержкой потоков; ошибка появилась в 0.3.46.
+
+
 Изменения в nginx 0.3.47                                          23.05.2006
 
     *) Добавление: директива upstream.
--- a/auto/cc/msvc	Tue May 23 00:00:00 2006 +0400
+++ b/auto/cc/msvc	Mon May 29 00:00:00 2006 +0400
@@ -49,7 +49,7 @@
     ;;
 esac
 
-# __cdecl, use with OpenSSL
+# __cdecl, use with OpenSSL, md5 asm, and sha1 asm
 #CPU_OPT="$CPU_OPT -Gd"
 # __stdcall
 #CPU_OPT="$CPU_OPT -Gz"
@@ -62,7 +62,6 @@
 
 # warnings
 
-#CFLAGS="$CFLAGS -W3"
 CFLAGS="$CFLAGS -W4"
 
 # stop on warning
--- a/auto/lib/conf	Tue May 23 00:00:00 2006 +0400
+++ b/auto/lib/conf	Mon May 29 00:00:00 2006 +0400
@@ -23,6 +23,18 @@
 
 fi
 
+if [ $USE_SHA1 = YES ]; then
+
+    if [ $OPENSSL != NONE -a $OPENSSL != NO ]; then
+        have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
+        SHA1=YES
+
+    else
+        . auto/lib/sha1/conf
+    fi
+
+fi
+
 if [ $USE_ZLIB = YES ]; then
     . auto/lib/zlib/conf
 fi
--- a/auto/lib/make	Tue May 23 00:00:00 2006 +0400
+++ b/auto/lib/make	Mon May 29 00:00:00 2006 +0400
@@ -10,6 +10,10 @@
     . auto/lib/md5/make
 fi
 
+if [ $SHA1 != NONE -a $SHA1 != NO -a $SHA1 != YES ]; then
+    . auto/lib/sha1/make
+fi
+
 if [ $OPENSSL != NONE -a $OPENSSL != NO -a $OPENSSL != YES ]; then
     . auto/lib/openssl/make
 fi
--- a/auto/lib/md5/makefile.bcc	Tue May 23 00:00:00 2006 +0400
+++ b/auto/lib/md5/makefile.bcc	Mon May 29 00:00:00 2006 +0400
@@ -8,7 +8,7 @@
 
 md5.lib:
 	bcc32 -c $(CFLAGS) -DMD5_ASM md5_dgst.c
-	tlib md5.lib +md5_dgst.obj +asm/m-win32.obj
+	tlib md5.lib +md5_dgst.obj +"asm\m-win32.obj"
 
 !else
 
--- a/auto/lib/md5/makefile.msvc	Tue May 23 00:00:00 2006 +0400
+++ b/auto/lib/md5/makefile.msvc	Mon May 29 00:00:00 2006 +0400
@@ -2,7 +2,7 @@
 # Copyright (C) Igor Sysoev
 
 
-CFLAGS = -nologo -MT -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN
+CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN
 
 !if "$(MD5_ASM)" == "YES"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/lib/sha1/conf	Mon May 29 00:00:00 2006 +0400
@@ -0,0 +1,81 @@
+
+# Copyright (C) Igor Sysoev
+
+
+if [ $SHA1 != NONE ]; then
+
+    CORE_INCS="$CORE_INCS $SHA1"
+
+    case "$NGX_CC_NAME" in
+
+        msvc* | owc* | bcc)
+            LINK_DEPS="$LINK_DEPS $SHA1/sha1.lib"
+            CORE_LIBS="$CORE_LIBS $SHA1/sha1.lib"
+        ;;
+
+        icc*)
+            LINK_DEPS="$LINK_DEPS $SHA1/libsha.a"
+
+            # to allow -ipo optimization we link with the *.o but not library
+            CORE_LIBS="$CORE_LIBS $SHA1/sha1_dgst.o"
+
+            if [ $SHA1_ASM = YES ]; then
+                CORE_LIBS="$CORE_LIBS $SHA1/asm/sx86-elf.o"
+            fi
+        ;;
+
+        *)
+            LINK_DEPS="$LINK_DEPS $SHA1/libsha.a"
+            CORE_LIBS="$CORE_LIBS $SHA1/libsha.a"
+            #CORE_LIBS="$CORE_LIBS -L $SHA1 -lsha"
+        ;;
+
+    esac
+
+else
+
+    if [ "$NGX_PLATFORM" != win32 ]; then
+        SHA1=NO
+
+        # FreeBSD
+
+        ngx_feature="sha1 in system md library"
+        ngx_feature_name=
+        ngx_feature_run=no
+        ngx_feature_incs="#include <sha.h>"
+        ngx_feature_libs="-lmd"
+        ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
+        . auto/feature
+
+
+        if [ $ngx_found = yes ]; then
+            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+            SHA1=YES
+            SHA1_LIB=md
+            ngx_found=no
+
+        else
+            if [ $SHA1 = NO ]; then
+
+               # OpenSSL crypto library
+
+               ngx_feature="OpenSSL sha1 crypto library"
+               ngx_feature_name=
+               ngx_feature_run=no
+               ngx_feature_incs="#include <openssl/sha.h>"
+               ngx_feature_libs="-lcrypto"
+               ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
+               . auto/feature
+            fi
+        fi
+
+
+        if [ $ngx_found = yes ]; then
+            have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
+            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+            SHA1=YES
+            SHA1_LIB=crypto
+        fi
+    fi
+
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/lib/sha1/make	Mon May 29 00:00:00 2006 +0400
@@ -0,0 +1,96 @@
+
+# Copyright (C) Igor Sysoev
+
+
+case "$NGX_CC_NAME" in
+
+    msvc*)
+        ngx_makefile=makefile.msvc
+        ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC SHA1_ASM=$SHA1_ASM"
+    ;;
+
+    owc*)
+        ngx_makefile=makefile.owc
+        ngx_opt="CPU_OPT=\"$CPU_OPT\""
+    ;;
+
+    bcc)
+        ngx_makefile=makefile.bcc
+        ngx_opt="-DCPU_OPT=\"$CPU_OPT\" -DSHA1_ASM=$SHA1_ASM"
+    ;;
+
+esac
+
+
+done=NO
+
+
+case "$NGX_PLATFORM" in
+
+    win32)
+        cp auto/lib/sha1/$ngx_makefile $SHA1
+
+        cat << END                                        >> $NGX_MAKEFILE
+
+`echo "$SHA1/sha1.lib:	$NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
+	cd `echo $SHA1 | sed -e "s/\//$ngx_regex_dirsep/g"`
+	\$(MAKE) -f $ngx_makefile $ngx_opt
+	cd ..\\..\\..
+
+END
+
+        done=YES
+    ;;
+
+    SunOS:*:i86pc)
+        if [ $SHA1_ASM = YES ]; then
+
+            cat << END                                        >> $NGX_MAKEFILE
+
+$SHA1/libsha.a:	$NGX_MAKEFILE
+	cd $SHA1 \\
+	&& \$(MAKE) CFLAGS="$SHA1_OPT -DSOL -DSHA1_ASM -DL_ENDIAN" \\
+		CC="\$(CC)" CPP="\$(CPP)" \\
+		SHA_ASM_OBJ=asm/sx86-sol.o clean libsha.a
+
+END
+
+            done=YES
+        fi
+    ;;
+
+    # FreeBSD: i386
+    # Linux: i686
+
+    *:i386 | *:i686)
+        if [ $SHA1_ASM = YES ]; then
+
+            cat << END                                        >> $NGX_MAKEFILE
+
+$SHA1/libsha.a:	$NGX_MAKEFILE
+	cd $SHA1 \\
+	&& \$(MAKE) CFLAGS="$SHA1_OPT -DELF -DSHA1_ASM -DL_ENDIAN" \\
+		CC="\$(CC)" CPP="\$(CPP)" \\
+		SHA_ASM_OBJ=asm/sx86-elf.o clean libsha.a
+
+END
+
+            done=YES
+        fi
+    ;;
+
+esac
+
+
+if [ $done = NO ]; then
+
+    cat << END                                                >> $NGX_MAKEFILE
+
+$SHA1/libsha.a:	$NGX_MAKEFILE
+	cd $SHA1 \\
+	&& \$(MAKE) CFLAGS="$SHA1_OPT" \\
+		CC="\$(CC)" SHA_ASM_OBJ= clean libsha.a
+
+END
+
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/lib/sha1/makefile.bcc	Mon May 29 00:00:00 2006 +0400
@@ -0,0 +1,19 @@
+
+# Copyright (C) Igor Sysoev
+
+
+CFLAGS = -q -O2 -tWM $(CPU_OPT) -DL_ENDIAN
+
+!if "$(SHA1_ASM)" == "YES"
+
+sha1.lib:
+	bcc32 -c $(CFLAGS) -DSHA1_ASM sha1dgst.c
+	tlib sha1.lib +sha1dgst.obj +"asm\s-win32.obj"
+
+!else
+
+sha1.lib:
+	bcc32 -c $(CFLAGS) sha1dgst.c
+	tlib sha1.lib +sha1dgst.obj
+
+!endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/lib/sha1/makefile.msvc	Mon May 29 00:00:00 2006 +0400
@@ -0,0 +1,19 @@
+
+# Copyright (C) Igor Sysoev
+
+
+CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN
+
+!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
+
+sha1.lib:
+	cl -c $(CFLAGS) sha1dgst.c
+	link -lib -out:sha1.lib sha1dgst.obj
+
+!endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/lib/sha1/makefile.owc	Mon May 29 00:00:00 2006 +0400
@@ -0,0 +1,9 @@
+
+# Copyright (C) Igor Sysoev
+
+
+CFLAGS = -zq -bt=nt -bm -ot -op -oi -oe -s $(CPU_OPT)
+
+sha1.lib:
+	wcl386 -c $(CFLAGS) -dL_ENDIAN sha1dgst.c
+	wlib -n sha1.lib sha1dgst.obj
--- a/auto/options	Tue May 23 00:00:00 2006 +0400
+++ b/auto/options	Mon May 29 00:00:00 2006 +0400
@@ -89,6 +89,11 @@
 MD5_OPT=
 MD5_ASM=NO
 
+USE_SHA1=NO
+SHA1=NONE
+SHA1_OPT=
+SHA1_ASM=NO
+
 USE_ZLIB=NO
 ZLIB=NONE
 ZLIB_OPT=
@@ -191,6 +196,10 @@
         --with-md5-opt=*)                MD5_OPT="$value"           ;;
         --with-md5-asm)                  MD5_ASM=YES                ;;
 
+        --with-sha1=*)                   SHA1="$value"              ;;
+        --with-sha1-opt=*)               SHA1_OPT="$value"          ;;
+        --with-sha1-asm)                 SHA1_ASM=YES               ;;
+
         --with-zlib=*)                   ZLIB="$value"              ;;
         --with-zlib-opt=*)               ZLIB_OPT="$value"          ;;
         --with-zlib-asm=*)               ZLIB_ASM="$value"          ;;
@@ -285,6 +294,10 @@
   --with-md5-opt=OPTIONS             set additional options for md5 building
   --with-md5-asm                     use md5 assembler sources
 
+  --with-sha1=DIR                    set path to sha1 library sources
+  --with-sha1-opt=OPTIONS            set additional options for sha1 building
+  --with-sha1-asm                    use sha1 assembler sources
+
   --with-zlib=DIR                    set path to zlib library sources
   --with-zlib-opt=OPTIONS            set additional options for zlib building
   --with-zlib-asm=CPU                use zlib assembler sources optimized
--- a/auto/summary	Tue May 23 00:00:00 2006 +0400
+++ b/auto/summary	Mon May 29 00:00:00 2006 +0400
@@ -63,6 +63,19 @@
     *)     echo "  + using md5 library: $MD5" ;;
 esac
 
+case $SHA1 in
+    YES)
+        case $OPENSSL in
+            NONE|NO)  echo "  + sha1: using system $SHA1_LIB library" ;;
+            *)        echo "  + sha1: using OpenSSL library" ;;
+        esac
+        ;;
+
+    NONE)  echo "  + sha1 library is not used" ;;
+    NO)    echo "  + sha1 library is not found" ;;
+    *)     echo "  + using sha1 library: $SHA1" ;;
+esac
+
 case $ZLIB in
     YES)   echo "  + using system zlib library" ;;
     NONE)  echo "  + zlib library is not used" ;;
--- a/src/core/nginx.h	Tue May 23 00:00:00 2006 +0400
+++ b/src/core/nginx.h	Mon May 29 00:00:00 2006 +0400
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.3.47"
+#define NGINX_VER          "nginx/0.3.48"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_OLDPID_EXT     ".oldbin"
--- a/src/http/modules/ngx_http_charset_filter_module.c	Tue May 23 00:00:00 2006 +0400
+++ b/src/http/modules/ngx_http_charset_filter_module.c	Mon May 29 00:00:00 2006 +0400
@@ -154,7 +154,7 @@
     ngx_uint_t                     i;
     ngx_http_charset_t            *charsets;
     ngx_http_charset_ctx_t        *ctx;
-    ngx_http_charset_loc_conf_t   *lcf;
+    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);
@@ -162,9 +162,9 @@
     ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module);
 
     if (ctx == NULL) {
-        lcf = ngx_http_get_module_loc_conf(r->main,
-                                           ngx_http_charset_filter_module);
-        charset = lcf->charset;
+        mlcf = ngx_http_get_module_loc_conf(r->main,
+                                            ngx_http_charset_filter_module);
+        charset = mlcf->charset;
 
         if (charset == NGX_HTTP_NO_CHARSET) {
             return ngx_http_next_header_filter(r);
@@ -174,19 +174,30 @@
         charset = ctx->charset;
     }
 
-    if (r->headers_out.content_type.len == 0) {
-        return ngx_http_next_header_filter(r);
-    }
+    charsets = mcf->charsets.elts;
+
+    if (r == r->main) {
+        if (r->headers_out.content_type.len == 0) {
+            return ngx_http_next_header_filter(r);
+        }
 
-    if (ngx_strncasecmp(r->headers_out.content_type.data, "text/", 5) != 0
-        && ngx_strncasecmp(r->headers_out.content_type.data,
-                           "application/x-javascript", 24) != 0)
-    {
-        return ngx_http_next_header_filter(r);
+        if (ngx_strncasecmp(r->headers_out.content_type.data, "text/", 5) != 0
+            && ngx_strncasecmp(r->headers_out.content_type.data,
+                               "application/x-javascript", 24) != 0)
+        {
+            return ngx_http_next_header_filter(r);
+        }
+
+    } else {
+        if (r->headers_out.content_type.len == 0) {
+            mlcf = ngx_http_get_module_loc_conf(r->main,
+                                                ngx_http_charset_filter_module);
+            source_charset = mlcf->source_charset;
+
+            goto found;
+        }
     }
 
-    charsets = mcf->charsets.elts;
-
     lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
 
     len = 0;
--- a/src/http/modules/ngx_http_proxy_module.c	Tue May 23 00:00:00 2006 +0400
+++ b/src/http/modules/ngx_http_proxy_module.c	Mon May 29 00:00:00 2006 +0400
@@ -1349,7 +1349,9 @@
 
     p = ngx_copy(p, h->value.data, prefix);
 
-    p = ngx_copy(p, pr->replacement.text.data, pr->replacement.text.len);
+    if (pr->replacement.text.len) {
+        p = ngx_copy(p, pr->replacement.text.data, pr->replacement.text.len);
+    }
 
     ngx_memcpy(p, h->value.data + prefix + pr->redirect.len,
                h->value.len - pr->redirect.len - prefix);
@@ -1694,7 +1696,14 @@
 
             pr->handler = ngx_http_proxy_rewrite_redirect_text;
             pr->redirect = conf->upstream.url;
-            pr->replacement.text = conf->upstream.location;
+
+            if (conf->upstream.uri.len) {
+                pr->replacement.text = conf->upstream.location;
+
+            } else {
+                pr->replacement.text.len = 0;
+                pr->replacement.text.data = NULL;
+            }
         }
     }
 
@@ -2263,7 +2272,14 @@
 
         pr->handler = ngx_http_proxy_rewrite_redirect_text;
         pr->redirect = plcf->upstream.url;
-        pr->replacement.text = plcf->upstream.location;
+
+        if (plcf->upstream.uri.len) {
+            pr->replacement.text = plcf->upstream.location;
+
+        } else {
+            pr->replacement.text.len = 0;
+            pr->replacement.text.data = NULL;
+        }
 
         return NGX_CONF_OK;
     }
--- a/src/http/modules/perl/ngx_http_perl_module.c	Tue May 23 00:00:00 2006 +0400
+++ b/src/http/modules/perl/ngx_http_perl_module.c	Mon May 29 00:00:00 2006 +0400
@@ -34,6 +34,12 @@
 } ngx_http_perl_variable_t;
 
 
+typedef struct {
+    SV                *sv;
+    PerlInterpreter   *perl;
+} ngx_http_perl_cleanup_t;
+
+
 #if (NGX_HTTP_SSI)
 static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r,
     ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params);
@@ -51,7 +57,7 @@
 static PerlInterpreter *
     ngx_http_perl_create_interpreter(ngx_http_perl_main_conf_t *pmcf,
     ngx_log_t *log);
-static ngx_int_t ngx_http_perl_run_requires(ngx_array_t *requires,
+static ngx_int_t ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires,
     ngx_log_t *log);
 static ngx_int_t ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r,
     SV *sub, ngx_str_t **args, ngx_str_t *handler, ngx_str_t *rv);
@@ -478,7 +484,7 @@
 ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf)
 {
 #if (NGX_HAVE_PERL_CLONE || NGX_HAVE_PERL_MULTIPLICITY)
-    ngx_pool_cleanup_t  *cln;
+    ngx_pool_cleanup_t       *cln;
 
     cln = ngx_pool_cleanup_add(cf->pool, 0);
     if (cln == NULL) {
@@ -504,7 +510,9 @@
 #if !(NGX_HAVE_PERL_CLONE || NGX_HAVE_PERL_MULTIPLICITY)
 
     if (perl) {
-        if (ngx_http_perl_run_requires(&pmcf->requires, cf->log) != NGX_OK) {
+        if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, cf->log)
+            != NGX_OK)
+        {
             return NGX_CONF_ERROR;
         }
 
@@ -613,7 +621,7 @@
         goto fail;
     }
 
-    if (ngx_http_perl_run_requires(&pmcf->requires, log) != NGX_OK) {
+    if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, log) != NGX_OK) {
         goto fail;
     }
 
@@ -634,7 +642,7 @@
 
 
 static ngx_int_t
-ngx_http_perl_run_requires(ngx_array_t *requires, ngx_log_t *log)
+ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
 {
     char       **script;
     STRLEN       len;
@@ -870,9 +878,11 @@
 static void
 ngx_http_perl_cleanup_sv(void *data)
 {
-    SV  *sv = data;
+    ngx_http_perl_cleanup_t  *cln = data;
 
-    SvREFCNT_dec(sv);
+    dTHXa(cln->perl);
+
+    SvREFCNT_dec(cln->sv);
 }
 
 
@@ -967,6 +977,7 @@
 
     ngx_str_t                  *value;
     ngx_pool_cleanup_t         *cln;
+    ngx_http_perl_cleanup_t    *pcln;
     ngx_http_core_loc_conf_t   *clcf;
     ngx_http_perl_main_conf_t  *pmcf;
 
@@ -986,7 +997,7 @@
         }
     }
 
-    cln = ngx_pool_cleanup_add(cf->pool, 0);
+    cln = ngx_pool_cleanup_add(cf->pool, sizeof(ngx_http_perl_cleanup_t));
     if (cln == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -1012,7 +1023,9 @@
     }
 
     cln->handler = ngx_http_perl_cleanup_sv;
-    cln->data = plcf->sub;
+    pcln = cln->data;
+    pcln->sv = plcf->sub;
+    pcln->perl = pmcf->perl;
 
     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
     clcf->handler = ngx_http_perl_handler;
@@ -1028,6 +1041,7 @@
     ngx_str_t                  *value;
     ngx_pool_cleanup_t         *cln;
     ngx_http_variable_t        *v;
+    ngx_http_perl_cleanup_t    *pcln;
     ngx_http_perl_variable_t   *pv;
     ngx_http_perl_main_conf_t  *pmcf;
 
@@ -1065,7 +1079,7 @@
         }
     }
 
-    cln = ngx_pool_cleanup_add(cf->pool, 0);
+    cln = ngx_pool_cleanup_add(cf->pool, sizeof(ngx_http_perl_cleanup_t));
     if (cln == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -1091,7 +1105,9 @@
     }
 
     cln->handler = ngx_http_perl_cleanup_sv;
-    cln->data = pv->sub;
+    pcln = cln->data;
+    pcln->sv = pv->sub;
+    pcln->perl = pmcf->perl;
 
     v->get_handler = ngx_http_perl_variable;
     v->data = (uintptr_t) pv;
--- a/src/http/ngx_http_core_module.c	Tue May 23 00:00:00 2006 +0400
+++ b/src/http/ngx_http_core_module.c	Mon May 29 00:00:00 2006 +0400
@@ -1330,7 +1330,6 @@
     ngx_http_update_location_config(r);
 
     r->internal = 1;
-    r->method = NGX_HTTP_GET;
 
     r->uri_changes--;
 
--- a/src/http/ngx_http_request.c	Tue May 23 00:00:00 2006 +0400
+++ b/src/http/ngx_http_request.c	Mon May 29 00:00:00 2006 +0400
@@ -1470,7 +1470,6 @@
         || rc == NGX_HTTP_CREATED
         || rc == NGX_HTTP_NO_CONTENT)
     {
-
         if (rc == NGX_HTTP_CLOSE) {
             ngx_http_close_request(r, rc);
             return;
--- a/src/http/ngx_http_script.c	Tue May 23 00:00:00 2006 +0400
+++ b/src/http/ngx_http_script.c	Mon May 29 00:00:00 2006 +0400
@@ -833,6 +833,10 @@
 
     e->status = code->status;
 
+    if (code->status == NGX_HTTP_NO_CONTENT) {
+        e->request->header_only = 1;
+    }
+
     e->ip += sizeof(ngx_http_script_return_code_t) - sizeof(uintptr_t);
 }
 
--- a/src/http/ngx_http_upstream.c	Tue May 23 00:00:00 2006 +0400
+++ b/src/http/ngx_http_upstream.c	Mon May 29 00:00:00 2006 +0400
@@ -1160,6 +1160,10 @@
             r->zero_in_uri = 1;
         }
 
+        if (r->method != NGX_HTTP_HEAD) {
+            r->method = NGX_HTTP_GET;
+        }
+
         ngx_http_internal_redirect(r, uri, &args);
         return;
     }