nginx-0.3.48-RELEASE import

    *) 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; the bug had appeared
       in 0.3.42.

    *) Bugfix: the ngx_http_perl_module could not be built, if the perl was
       built with the threads support; the bug had appeared in 0.3.46.
diff --git a/auto/lib/conf b/auto/lib/conf
index 62d6029..e961034 100644
--- a/auto/lib/conf
+++ b/auto/lib/conf
@@ -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
diff --git a/auto/lib/make b/auto/lib/make
index 60cd7bc..170311c 100644
--- a/auto/lib/make
+++ b/auto/lib/make
@@ -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
diff --git a/auto/lib/md5/makefile.bcc b/auto/lib/md5/makefile.bcc
index 837f2df..6d2151b 100644
--- a/auto/lib/md5/makefile.bcc
+++ b/auto/lib/md5/makefile.bcc
@@ -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
 
diff --git a/auto/lib/md5/makefile.msvc b/auto/lib/md5/makefile.msvc
index 68f5cc4..aaffe18 100644
--- a/auto/lib/md5/makefile.msvc
+++ b/auto/lib/md5/makefile.msvc
@@ -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"
 
diff --git a/auto/lib/sha1/conf b/auto/lib/sha1/conf
new file mode 100644
index 0000000..a1e20c9
--- /dev/null
+++ b/auto/lib/sha1/conf
@@ -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
diff --git a/auto/lib/sha1/make b/auto/lib/sha1/make
new file mode 100644
index 0000000..bd1036e
--- /dev/null
+++ b/auto/lib/sha1/make
@@ -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
diff --git a/auto/lib/sha1/makefile.bcc b/auto/lib/sha1/makefile.bcc
new file mode 100644
index 0000000..255e56a
--- /dev/null
+++ b/auto/lib/sha1/makefile.bcc
@@ -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
diff --git a/auto/lib/sha1/makefile.msvc b/auto/lib/sha1/makefile.msvc
new file mode 100644
index 0000000..2ec55d5
--- /dev/null
+++ b/auto/lib/sha1/makefile.msvc
@@ -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
diff --git a/auto/lib/sha1/makefile.owc b/auto/lib/sha1/makefile.owc
new file mode 100644
index 0000000..767870d
--- /dev/null
+++ b/auto/lib/sha1/makefile.owc
@@ -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