Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

nginx 0.3.55

    *) Feature: the "stub" parameter in the "include" SSI command.

    *) Feature: the "block" SSI command.

    *) Feature: the unicode2nginx script was added to contrib.

    *) Bugfix: if a "root" was specified by variable only, then the root
       was relative to a server prefix.

    *) Bugfix: if the request contained "//" or "/./" and escaped symbols
       after them, then the proxied request was sent unescaped.

    *) Bugfix: the $r->headers_in("Cookie") of the ngx_http_perl_module now
       returns all "Cookie" header lines.

    *) Bugfix: a segmentation fault occurred if
       "client_body_in_file_only on" was used and nginx switched to a next
       upstream.

    *) Bugfix: on some condition while reconfiguration character codes
       inside the "charset_map" may be treated invalid; bug appeared in
       0.3.50.
  • Loading branch information...
commit 794e7a3b811f05a0f5a76746ff8b9e399b50ab6a 1 parent 9909025
Igor Sysoev authored committed

Showing 48 changed files with 871 additions and 118 deletions. Show diff stats Hide diff stats

  1. +27 1 CHANGES
  2. +28 1 CHANGES.ru
  3. +4 2 auto/make
  4. +6 0 conf/koi-utf
  5. +1 0  conf/mime.types
  6. +4 0 conf/win-utf
  7. +13 4 contrib/README
  8. +131 0 contrib/unicode2nginx/koi-utf
  9. +45 0 contrib/unicode2nginx/unicode-to-nginx.pl
  10. +130 0 contrib/unicode2nginx/win-utf
  11. +1 1  src/core/nginx.h
  12. +2 5 src/core/ngx_file.c
  13. +2 2 src/event/ngx_event.c
  14. +1 1  src/http/modules/ngx_http_access_module.c
  15. +2 2 src/http/modules/ngx_http_addition_filter_module.c
  16. +1 1  src/http/modules/ngx_http_auth_basic_module.c
  17. +1 1  src/http/modules/ngx_http_autoindex_module.c
  18. +3 0  src/http/modules/ngx_http_charset_filter_module.c
  19. +5 2 src/http/modules/ngx_http_chunked_filter_module.c
  20. +1 1  src/http/modules/ngx_http_dav_module.c
  21. +1 1  src/http/modules/ngx_http_empty_gif_module.c
  22. +1 1  src/http/modules/ngx_http_fastcgi_module.c
  23. +1 1  src/http/modules/ngx_http_index_module.c
  24. +1 1  src/http/modules/ngx_http_log_module.c
  25. +1 1  src/http/modules/ngx_http_memcached_module.c
  26. +1 1  src/http/modules/ngx_http_proxy_module.c
  27. +1 1  src/http/modules/ngx_http_realip_module.c
  28. +1 1  src/http/modules/ngx_http_rewrite_module.c
  29. +287 27 src/http/modules/ngx_http_ssi_filter_module.c
  30. +4 1 src/http/modules/ngx_http_ssi_filter_module.h
  31. +1 1  src/http/modules/ngx_http_ssl_module.c
  32. +1 1  src/http/modules/ngx_http_stub_status_module.c
  33. +1 1  src/http/modules/ngx_http_userid_filter_module.c
  34. +92 12 src/http/modules/perl/nginx.xs
  35. +1 1  src/http/modules/perl/ngx_http_perl_module.c
  36. +0 3  src/http/ngx_http.h
  37. +1 0  src/http/ngx_http_copy_filter_module.c
  38. +16 7 src/http/ngx_http_core_module.c
  39. +1 2  src/http/ngx_http_core_module.h
  40. +2 0  src/http/ngx_http_header_filter_module.c
  41. +2 0  src/http/ngx_http_parse.c
  42. +0 1  src/http/ngx_http_postpone_filter_module.c
  43. +23 10 src/http/ngx_http_request.c
  44. +2 0  src/http/ngx_http_request.h
  45. +2 2 src/http/ngx_http_request_body.c
  46. +1 0  src/http/ngx_http_upstream.c
  47. +9 7 src/http/ngx_http_variables.c
  48. +9 10 src/http/ngx_http_write_filter_module.c
28 CHANGES
... ... @@ -1,4 +1,30 @@
1 1
  2 +Changes with nginx 0.3.55 28 Jul 2006
  3 +
  4 + *) Feature: the "stub" parameter in the "include" SSI command.
  5 +
  6 + *) Feature: the "block" SSI command.
  7 +
  8 + *) Feature: the unicode2nginx script was added to contrib.
  9 +
  10 + *) Bugfix: if a "root" was specified by variable only, then the root
  11 + was relative to a server prefix.
  12 +
  13 + *) Bugfix: if the request contained "//" or "/./" and escaped symbols
  14 + after them, then the proxied request was sent unescaped.
  15 +
  16 + *) Bugfix: the $r->headers_in("Cookie") of the ngx_http_perl_module now
  17 + returns all "Cookie" header lines.
  18 +
  19 + *) Bugfix: a segmentation fault occurred if
  20 + "client_body_in_file_only on" was used and nginx was switches to a
  21 + next upstream.
  22 +
  23 + *) Bugfix: on some condition while reconfiguration character codes
  24 + inside the "charset_map" may be treated invalid; bug appeared in
  25 + 0.3.50.
  26 +
  27 +
2 28 Changes with nginx 0.3.54 11 Jul 2006
3 29
4 30 *) Feature: nginx now logs the subrequest information to the error log.
@@ -156,7 +182,7 @@ Changes with nginx 0.3.45 06 May 2006
156 182
157 183 Changes with nginx 0.3.44 04 May 2006
158 184
159   - *) Feature: the "wait" parameter in the SSI "include" command.
  185 + *) Feature: the "wait" parameter in the "include" SSI command.
160 186
161 187 *) Feature: the Ukrainian and Byelorussian characters were added to
162 188 koi-win conversion table.
29 CHANGES.ru
... ... @@ -1,4 +1,31 @@
1 1
  2 +��������� � nginx 0.3.55 28.07.2006
  3 +
  4 + *) ����������: �������� stub � ������� SSI include.
  5 +
  6 + *) ����������: ������� SSI block.
  7 +
  8 + *) ����������: ������ unicode2nginx �������� � contrib.
  9 +
  10 + *) �����������: ���� root ��� ����� ������ ����������, �� ������
  11 + ��������� ������������ �������� �������.
  12 +
  13 + *) �����������: ���� � ������� ��� "//" ��� "/.", � ����� �����
  14 + �������������� ������� � ���� "%XX", �� ������������ ������
  15 + ����������� ����������������.
  16 +
  17 + *) �����������: ����� $r->headers_in("Cookie") ������
  18 + ngx_http_perl_module ������ ���������� ��� ������ "Cookie" �
  19 + ��������� �������.
  20 +
  21 + *) �����������: ���������� segmentation fault, ���� �������������
  22 + "client_body_in_file_only on" � ������� ������� � ���������� �������.
  23 +
  24 + *) �����������: ��� ��������� �������� �� ����� ���������������� ����
  25 + �������� � ������ ��������� charset_map ����� ��������� ���������;
  26 + ������ ��������� � 0.3.50.
  27 +
  28 +
2 29 ��������� � nginx 0.3.54 11.07.2006
3 30
4 31 *) ����������: nginx ������ ���������� � ��� ���������� � �����������.
@@ -161,7 +188,7 @@
161 188
162 189 ��������� � nginx 0.3.44 04.05.2006
163 190
164   - *) ����������: �������� wait � ������� SSI inlcude.
  191 + *) ����������: �������� wait � ������� SSI include.
165 192
166 193 *) ����������: � ������� ������������� koi-win ��������� ���������� �
167 194 ����������� �������.
6 auto/make
@@ -175,8 +175,10 @@ ngx_objs=`echo $ngx_all_objs $ngx_modules_obj \
175 175 | sed -e "s/ *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \
176 176 -e "s/\//$ngx_regex_dirsep/g"`
177 177
178   -ngx_libs=${CORE_LIBS:+`echo $NGX_LD_OPT $CORE_LIBS \
179   - | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
  178 +if test -n "$NGX_LD_OPT$CORE_LIBS"; then
  179 + ngx_libs=`echo $NGX_LD_OPT $CORE_LIBS \
  180 + | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`
  181 +fi
180 182
181 183 ngx_link=${CORE_LINK:+`echo $CORE_LINK \
182 184 | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
6 conf/koi-utf
... ... @@ -1,4 +1,10 @@
1 1
  2 +# This map is not a full koi8-r <> utf8 map: it does not contain
  3 +# box-drawing and some other characters. Besides this map contains
  4 +# several koi8-u and Byelorussian letters which are not in koi8-r.
  5 +# If you need a full and standard map, use contrib/unicode2nginx/koi-utf
  6 +# map instead.
  7 +
2 8 charset_map koi8-r utf-8 {
3 9
4 10 80 E282AC ; # euro
1  conf/mime.types
@@ -14,6 +14,7 @@ types {
14 14 image/png png;
15 15 image/x-icon ico;
16 16 image/x-jng jng;
  17 + image/vnd.wap.wbmp wbmp;
17 18
18 19 application/java-archive jar war ear;
19 20 application/mac-binhex40 hqx;
4 conf/win-utf
... ... @@ -1,4 +1,8 @@
1 1
  2 +# This map is not a full windows-1251 <> utf8 map: it does not
  3 +# contain Serbian and Macedonian letters. If you need a full map,
  4 +# use contrib/unicode2nginx/win-utf map instead.
  5 +
2 6 charset_map windows-1251 utf-8 {
3 7
4 8 82 E2809A ; # single low-9 quotation mark
17 contrib/README
... ... @@ -1,6 +1,15 @@
1 1
2   -geo2nginx.pl by Andrei Nigmatulin
  2 +geo2nginx.pl by Andrei Nigmatulin
  3 +
  4 + The perl script to convert CSV geoip database ( free download
  5 + at http://www.maxmind.com/app/geoip_country ) to format, suitable
  6 + for use by the ngx_http_geo_module.
  7 +
  8 +
  9 +unicode2nginx by Maxim Dounin
  10 +
  11 + The perl script to convert unicode mappings ( available
  12 + at http://www.unicode.org/Public/MAPPINGS/ ) to the nginx
  13 + configuration file format.
  14 + Two generated full maps for windows-1251 and koi8-r.
3 15
4   - The perl script to convert CSV geoip database (free download
5   - at http://www.maxmind.com/app/geoip_country) to format, suitable
6   - for use with ngx_http_geo_module.
131 contrib/unicode2nginx/koi-utf
... ... @@ -0,0 +1,131 @@
  1 +charset_map koi8-r utf-8 {
  2 +
  3 + 80 E29480 ; # BOX DRAWINGS LIGHT HORIZONTAL
  4 + 81 E29482 ; # BOX DRAWINGS LIGHT VERTICAL
  5 + 82 E2948C ; # BOX DRAWINGS LIGHT DOWN AND RIGHT
  6 + 83 E29490 ; # BOX DRAWINGS LIGHT DOWN AND LEFT
  7 + 84 E29494 ; # BOX DRAWINGS LIGHT UP AND RIGHT
  8 + 85 E29498 ; # BOX DRAWINGS LIGHT UP AND LEFT
  9 + 86 E2949C ; # BOX DRAWINGS LIGHT VERTICAL AND RIGHT
  10 + 87 E294A4 ; # BOX DRAWINGS LIGHT VERTICAL AND LEFT
  11 + 88 E294AC ; # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
  12 + 89 E294B4 ; # BOX DRAWINGS LIGHT UP AND HORIZONTAL
  13 + 8A E294BC ; # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
  14 + 8B E29680 ; # UPPER HALF BLOCK
  15 + 8C E29684 ; # LOWER HALF BLOCK
  16 + 8D E29688 ; # FULL BLOCK
  17 + 8E E2968C ; # LEFT HALF BLOCK
  18 + 8F E29690 ; # RIGHT HALF BLOCK
  19 + 90 E29691 ; # LIGHT SHADE
  20 + 91 E29692 ; # MEDIUM SHADE
  21 + 92 E29693 ; # DARK SHADE
  22 + 93 E28CA0 ; # TOP HALF INTEGRAL
  23 + 94 E296A0 ; # BLACK SQUARE
  24 + 95 E28899 ; # BULLET OPERATOR
  25 + 96 E2889A ; # SQUARE ROOT
  26 + 97 E28988 ; # ALMOST EQUAL TO
  27 + 98 E289A4 ; # LESS-THAN OR EQUAL TO
  28 + 99 E289A5 ; # GREATER-THAN OR EQUAL TO
  29 + 9A C2A0 ; # NO-BREAK SPACE
  30 + 9B E28CA1 ; # BOTTOM HALF INTEGRAL
  31 + 9C C2B0 ; # DEGREE SIGN
  32 + 9D C2B2 ; # SUPERSCRIPT TWO
  33 + 9E C2B7 ; # MIDDLE DOT
  34 + 9F C3B7 ; # DIVISION SIGN
  35 + A0 E29590 ; # BOX DRAWINGS DOUBLE HORIZONTAL
  36 + A1 E29591 ; # BOX DRAWINGS DOUBLE VERTICAL
  37 + A2 E29592 ; # BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
  38 + A3 D191 ; # CYRILLIC SMALL LETTER IO
  39 + A4 E29593 ; # BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
  40 + A5 E29594 ; # BOX DRAWINGS DOUBLE DOWN AND RIGHT
  41 + A6 E29595 ; # BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
  42 + A7 E29596 ; # BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
  43 + A8 E29597 ; # BOX DRAWINGS DOUBLE DOWN AND LEFT
  44 + A9 E29598 ; # BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
  45 + AA E29599 ; # BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
  46 + AB E2959A ; # BOX DRAWINGS DOUBLE UP AND RIGHT
  47 + AC E2959B ; # BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
  48 + AD E2959C ; # BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
  49 + AE E2959D ; # BOX DRAWINGS DOUBLE UP AND LEFT
  50 + AF E2959E ; # BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
  51 + B0 E2959F ; # BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
  52 + B1 E295A0 ; # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
  53 + B2 E295A1 ; # BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
  54 + B3 D081 ; # CYRILLIC CAPITAL LETTER IO
  55 + B4 E295A2 ; # BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
  56 + B5 E295A3 ; # BOX DRAWINGS DOUBLE VERTICAL AND LEFT
  57 + B6 E295A4 ; # BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
  58 + B7 E295A5 ; # BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
  59 + B8 E295A6 ; # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
  60 + B9 E295A7 ; # BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
  61 + BA E295A8 ; # BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
  62 + BB E295A9 ; # BOX DRAWINGS DOUBLE UP AND HORIZONTAL
  63 + BC E295AA ; # BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
  64 + BD E295AB ; # BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
  65 + BE E295AC ; # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
  66 + BF C2A9 ; # COPYRIGHT SIGN
  67 + C0 D18E ; # CYRILLIC SMALL LETTER YU
  68 + C1 D0B0 ; # CYRILLIC SMALL LETTER A
  69 + C2 D0B1 ; # CYRILLIC SMALL LETTER BE
  70 + C3 D186 ; # CYRILLIC SMALL LETTER TSE
  71 + C4 D0B4 ; # CYRILLIC SMALL LETTER DE
  72 + C5 D0B5 ; # CYRILLIC SMALL LETTER IE
  73 + C6 D184 ; # CYRILLIC SMALL LETTER EF
  74 + C7 D0B3 ; # CYRILLIC SMALL LETTER GHE
  75 + C8 D185 ; # CYRILLIC SMALL LETTER HA
  76 + C9 D0B8 ; # CYRILLIC SMALL LETTER I
  77 + CA D0B9 ; # CYRILLIC SMALL LETTER SHORT I
  78 + CB D0BA ; # CYRILLIC SMALL LETTER KA
  79 + CC D0BB ; # CYRILLIC SMALL LETTER EL
  80 + CD D0BC ; # CYRILLIC SMALL LETTER EM
  81 + CE D0BD ; # CYRILLIC SMALL LETTER EN
  82 + CF D0BE ; # CYRILLIC SMALL LETTER O
  83 + D0 D0BF ; # CYRILLIC SMALL LETTER PE
  84 + D1 D18F ; # CYRILLIC SMALL LETTER YA
  85 + D2 D180 ; # CYRILLIC SMALL LETTER ER
  86 + D3 D181 ; # CYRILLIC SMALL LETTER ES
  87 + D4 D182 ; # CYRILLIC SMALL LETTER TE
  88 + D5 D183 ; # CYRILLIC SMALL LETTER U
  89 + D6 D0B6 ; # CYRILLIC SMALL LETTER ZHE
  90 + D7 D0B2 ; # CYRILLIC SMALL LETTER VE
  91 + D8 D18C ; # CYRILLIC SMALL LETTER SOFT SIGN
  92 + D9 D18B ; # CYRILLIC SMALL LETTER YERU
  93 + DA D0B7 ; # CYRILLIC SMALL LETTER ZE
  94 + DB D188 ; # CYRILLIC SMALL LETTER SHA
  95 + DC D18D ; # CYRILLIC SMALL LETTER E
  96 + DD D189 ; # CYRILLIC SMALL LETTER SHCHA
  97 + DE D187 ; # CYRILLIC SMALL LETTER CHE
  98 + DF D18A ; # CYRILLIC SMALL LETTER HARD SIGN
  99 + E0 D0AE ; # CYRILLIC CAPITAL LETTER YU
  100 + E1 D090 ; # CYRILLIC CAPITAL LETTER A
  101 + E2 D091 ; # CYRILLIC CAPITAL LETTER BE
  102 + E3 D0A6 ; # CYRILLIC CAPITAL LETTER TSE
  103 + E4 D094 ; # CYRILLIC CAPITAL LETTER DE
  104 + E5 D095 ; # CYRILLIC CAPITAL LETTER IE
  105 + E6 D0A4 ; # CYRILLIC CAPITAL LETTER EF
  106 + E7 D093 ; # CYRILLIC CAPITAL LETTER GHE
  107 + E8 D0A5 ; # CYRILLIC CAPITAL LETTER HA
  108 + E9 D098 ; # CYRILLIC CAPITAL LETTER I
  109 + EA D099 ; # CYRILLIC CAPITAL LETTER SHORT I
  110 + EB D09A ; # CYRILLIC CAPITAL LETTER KA
  111 + EC D09B ; # CYRILLIC CAPITAL LETTER EL
  112 + ED D09C ; # CYRILLIC CAPITAL LETTER EM
  113 + EE D09D ; # CYRILLIC CAPITAL LETTER EN
  114 + EF D09E ; # CYRILLIC CAPITAL LETTER O
  115 + F0 D09F ; # CYRILLIC CAPITAL LETTER PE
  116 + F1 D0AF ; # CYRILLIC CAPITAL LETTER YA
  117 + F2 D0A0 ; # CYRILLIC CAPITAL LETTER ER
  118 + F3 D0A1 ; # CYRILLIC CAPITAL LETTER ES
  119 + F4 D0A2 ; # CYRILLIC CAPITAL LETTER TE
  120 + F5 D0A3 ; # CYRILLIC CAPITAL LETTER U
  121 + F6 D096 ; # CYRILLIC CAPITAL LETTER ZHE
  122 + F7 D092 ; # CYRILLIC CAPITAL LETTER VE
  123 + F8 D0AC ; # CYRILLIC CAPITAL LETTER SOFT SIGN
  124 + F9 D0AB ; # CYRILLIC CAPITAL LETTER YERU
  125 + FA D097 ; # CYRILLIC CAPITAL LETTER ZE
  126 + FB D0A8 ; # CYRILLIC CAPITAL LETTER SHA
  127 + FC D0AD ; # CYRILLIC CAPITAL LETTER E
  128 + FD D0A9 ; # CYRILLIC CAPITAL LETTER SHCHA
  129 + FE D0A7 ; # CYRILLIC CAPITAL LETTER CHE
  130 + FF D0AA ; # CYRILLIC CAPITAL LETTER HARD SIGN
  131 +}
45 contrib/unicode2nginx/unicode-to-nginx.pl
... ... @@ -0,0 +1,45 @@
  1 +#!/usr/bin/perl -w
  2 +
  3 +# Convert unicode mappings to nginx configuration file format.
  4 +
  5 +# You may find useful mappings in various places, including
  6 +# unicode.org official site:
  7 +#
  8 +# http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT
  9 +# http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT
  10 +
  11 +# Needs perl 5.6 or later.
  12 +
  13 +# Written by Maxim Dounin, mdounin@rambler-co.ru
  14 +
  15 +###############################################################################
  16 +
  17 +require 5.006;
  18 +
  19 +while (<>) {
  20 + # Skip comments and empty lines
  21 +
  22 + next if /^#/;
  23 + next if /^\s*$/;
  24 + chomp;
  25 +
  26 + # Convert mappings
  27 +
  28 + if (/^\s*0x(..)\s*0x(....)\s*(#.*)/) {
  29 + # Mapping <from-code> <unicode-code> "#" <unicode-name>
  30 + my $cs_code = $1;
  31 + my $un_code = $2;
  32 + my $un_name = $3;
  33 +
  34 + # Produce UTF-8 sequence from character code;
  35 +
  36 + my $un_utf8 = join('', map { sprintf("%02X", $_) } unpack("C*", pack("U", hex($un_code))));
  37 +
  38 + print " $cs_code $un_utf8 ; $un_name\n";
  39 +
  40 + } else {
  41 + warn "Unrecognized line: '$_'";
  42 + }
  43 +}
  44 +
  45 +###############################################################################
130 contrib/unicode2nginx/win-utf
... ... @@ -0,0 +1,130 @@
  1 +charset_map windows-1251 utf-8 {
  2 +
  3 + 80 D082 ; #CYRILLIC CAPITAL LETTER DJE
  4 + 81 D083 ; #CYRILLIC CAPITAL LETTER GJE
  5 + 82 E2809A ; #SINGLE LOW-9 QUOTATION MARK
  6 + 83 D193 ; #CYRILLIC SMALL LETTER GJE
  7 + 84 E2809E ; #DOUBLE LOW-9 QUOTATION MARK
  8 + 85 E280A6 ; #HORIZONTAL ELLIPSIS
  9 + 86 E280A0 ; #DAGGER
  10 + 87 E280A1 ; #DOUBLE DAGGER
  11 + 88 E282AC ; #EURO SIGN
  12 + 89 E280B0 ; #PER MILLE SIGN
  13 + 8A D089 ; #CYRILLIC CAPITAL LETTER LJE
  14 + 8B E280B9 ; #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
  15 + 8C D08A ; #CYRILLIC CAPITAL LETTER NJE
  16 + 8D D08C ; #CYRILLIC CAPITAL LETTER KJE
  17 + 8E D08B ; #CYRILLIC CAPITAL LETTER TSHE
  18 + 8F D08F ; #CYRILLIC CAPITAL LETTER DZHE
  19 + 90 D192 ; #CYRILLIC SMALL LETTER DJE
  20 + 91 E28098 ; #LEFT SINGLE QUOTATION MARK
  21 + 92 E28099 ; #RIGHT SINGLE QUOTATION MARK
  22 + 93 E2809C ; #LEFT DOUBLE QUOTATION MARK
  23 + 94 E2809D ; #RIGHT DOUBLE QUOTATION MARK
  24 + 95 E280A2 ; #BULLET
  25 + 96 E28093 ; #EN DASH
  26 + 97 E28094 ; #EM DASH
  27 + 99 E284A2 ; #TRADE MARK SIGN
  28 + 9A D199 ; #CYRILLIC SMALL LETTER LJE
  29 + 9B E280BA ; #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
  30 + 9C D19A ; #CYRILLIC SMALL LETTER NJE
  31 + 9D D19C ; #CYRILLIC SMALL LETTER KJE
  32 + 9E D19B ; #CYRILLIC SMALL LETTER TSHE
  33 + 9F D19F ; #CYRILLIC SMALL LETTER DZHE
  34 + A0 C2A0 ; #NO-BREAK SPACE
  35 + A1 D08E ; #CYRILLIC CAPITAL LETTER SHORT U
  36 + A2 D19E ; #CYRILLIC SMALL LETTER SHORT U
  37 + A3 D088 ; #CYRILLIC CAPITAL LETTER JE
  38 + A4 C2A4 ; #CURRENCY SIGN
  39 + A5 D290 ; #CYRILLIC CAPITAL LETTER GHE WITH UPTURN
  40 + A6 C2A6 ; #BROKEN BAR
  41 + A7 C2A7 ; #SECTION SIGN
  42 + A8 D081 ; #CYRILLIC CAPITAL LETTER IO
  43 + A9 C2A9 ; #COPYRIGHT SIGN
  44 + AA D084 ; #CYRILLIC CAPITAL LETTER UKRAINIAN IE
  45 + AB C2AB ; #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
  46 + AC C2AC ; #NOT SIGN
  47 + AD C2AD ; #SOFT HYPHEN
  48 + AE C2AE ; #REGISTERED SIGN
  49 + AF D087 ; #CYRILLIC CAPITAL LETTER YI
  50 + B0 C2B0 ; #DEGREE SIGN
  51 + B1 C2B1 ; #PLUS-MINUS SIGN
  52 + B2 D086 ; #CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
  53 + B3 D196 ; #CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
  54 + B4 D291 ; #CYRILLIC SMALL LETTER GHE WITH UPTURN
  55 + B5 C2B5 ; #MICRO SIGN
  56 + B6 C2B6 ; #PILCROW SIGN
  57 + B7 C2B7 ; #MIDDLE DOT
  58 + B8 D191 ; #CYRILLIC SMALL LETTER IO
  59 + B9 E28496 ; #NUMERO SIGN
  60 + BA D194 ; #CYRILLIC SMALL LETTER UKRAINIAN IE
  61 + BB C2BB ; #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
  62 + BC D198 ; #CYRILLIC SMALL LETTER JE
  63 + BD D085 ; #CYRILLIC CAPITAL LETTER DZE
  64 + BE D195 ; #CYRILLIC SMALL LETTER DZE
  65 + BF D197 ; #CYRILLIC SMALL LETTER YI
  66 + C0 D090 ; #CYRILLIC CAPITAL LETTER A
  67 + C1 D091 ; #CYRILLIC CAPITAL LETTER BE
  68 + C2 D092 ; #CYRILLIC CAPITAL LETTER VE
  69 + C3 D093 ; #CYRILLIC CAPITAL LETTER GHE
  70 + C4 D094 ; #CYRILLIC CAPITAL LETTER DE
  71 + C5 D095 ; #CYRILLIC CAPITAL LETTER IE
  72 + C6 D096 ; #CYRILLIC CAPITAL LETTER ZHE
  73 + C7 D097 ; #CYRILLIC CAPITAL LETTER ZE
  74 + C8 D098 ; #CYRILLIC CAPITAL LETTER I
  75 + C9 D099 ; #CYRILLIC CAPITAL LETTER SHORT I
  76 + CA D09A ; #CYRILLIC CAPITAL LETTER KA
  77 + CB D09B ; #CYRILLIC CAPITAL LETTER EL
  78 + CC D09C ; #CYRILLIC CAPITAL LETTER EM
  79 + CD D09D ; #CYRILLIC CAPITAL LETTER EN
  80 + CE D09E ; #CYRILLIC CAPITAL LETTER O
  81 + CF D09F ; #CYRILLIC CAPITAL LETTER PE
  82 + D0 D0A0 ; #CYRILLIC CAPITAL LETTER ER
  83 + D1 D0A1 ; #CYRILLIC CAPITAL LETTER ES
  84 + D2 D0A2 ; #CYRILLIC CAPITAL LETTER TE
  85 + D3 D0A3 ; #CYRILLIC CAPITAL LETTER U
  86 + D4 D0A4 ; #CYRILLIC CAPITAL LETTER EF
  87 + D5 D0A5 ; #CYRILLIC CAPITAL LETTER HA
  88 + D6 D0A6 ; #CYRILLIC CAPITAL LETTER TSE
  89 + D7 D0A7 ; #CYRILLIC CAPITAL LETTER CHE
  90 + D8 D0A8 ; #CYRILLIC CAPITAL LETTER SHA
  91 + D9 D0A9 ; #CYRILLIC CAPITAL LETTER SHCHA
  92 + DA D0AA ; #CYRILLIC CAPITAL LETTER HARD SIGN
  93 + DB D0AB ; #CYRILLIC CAPITAL LETTER YERU
  94 + DC D0AC ; #CYRILLIC CAPITAL LETTER SOFT SIGN
  95 + DD D0AD ; #CYRILLIC CAPITAL LETTER E
  96 + DE D0AE ; #CYRILLIC CAPITAL LETTER YU
  97 + DF D0AF ; #CYRILLIC CAPITAL LETTER YA
  98 + E0 D0B0 ; #CYRILLIC SMALL LETTER A
  99 + E1 D0B1 ; #CYRILLIC SMALL LETTER BE
  100 + E2 D0B2 ; #CYRILLIC SMALL LETTER VE
  101 + E3 D0B3 ; #CYRILLIC SMALL LETTER GHE
  102 + E4 D0B4 ; #CYRILLIC SMALL LETTER DE
  103 + E5 D0B5 ; #CYRILLIC SMALL LETTER IE
  104 + E6 D0B6 ; #CYRILLIC SMALL LETTER ZHE
  105 + E7 D0B7 ; #CYRILLIC SMALL LETTER ZE
  106 + E8 D0B8 ; #CYRILLIC SMALL LETTER I
  107 + E9 D0B9 ; #CYRILLIC SMALL LETTER SHORT I
  108 + EA D0BA ; #CYRILLIC SMALL LETTER KA
  109 + EB D0BB ; #CYRILLIC SMALL LETTER EL
  110 + EC D0BC ; #CYRILLIC SMALL LETTER EM
  111 + ED D0BD ; #CYRILLIC SMALL LETTER EN
  112 + EE D0BE ; #CYRILLIC SMALL LETTER O
  113 + EF D0BF ; #CYRILLIC SMALL LETTER PE
  114 + F0 D180 ; #CYRILLIC SMALL LETTER ER
  115 + F1 D181 ; #CYRILLIC SMALL LETTER ES
  116 + F2 D182 ; #CYRILLIC SMALL LETTER TE
  117 + F3 D183 ; #CYRILLIC SMALL LETTER U
  118 + F4 D184 ; #CYRILLIC SMALL LETTER EF
  119 + F5 D185 ; #CYRILLIC SMALL LETTER HA
  120 + F6 D186 ; #CYRILLIC SMALL LETTER TSE
  121 + F7 D187 ; #CYRILLIC SMALL LETTER CHE
  122 + F8 D188 ; #CYRILLIC SMALL LETTER SHA
  123 + F9 D189 ; #CYRILLIC SMALL LETTER SHCHA
  124 + FA D18A ; #CYRILLIC SMALL LETTER HARD SIGN
  125 + FB D18B ; #CYRILLIC SMALL LETTER YERU
  126 + FC D18C ; #CYRILLIC SMALL LETTER SOFT SIGN
  127 + FD D18D ; #CYRILLIC SMALL LETTER E
  128 + FE D18E ; #CYRILLIC SMALL LETTER YU
  129 + FF D18F ; #CYRILLIC SMALL LETTER YA
  130 +}
2  src/core/nginx.h
@@ -8,7 +8,7 @@
8 8 #define _NGINX_H_INCLUDED_
9 9
10 10
11   -#define NGINX_VER "nginx/0.3.54"
  11 +#define NGINX_VER "nginx/0.3.55"
12 12
13 13 #define NGINX_VAR "NGINX"
14 14 #define NGX_OLDPID_EXT ".oldbin"
7 src/core/ngx_file.c
@@ -25,11 +25,8 @@ ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
25 25 return rc;
26 26 }
27 27
28   - if (tf->log_level == NGX_LOG_NOTICE) {
29   - ngx_log_error(NGX_LOG_NOTICE, tf->file.log, 0, tf->warn);
30   -
31   - } else if (tf->log_level == NGX_LOG_WARN) {
32   - ngx_log_error(NGX_LOG_WARN, tf->file.log, 0, "%s %V",
  28 + if (tf->log_level) {
  29 + ngx_log_error(tf->log_level, tf->file.log, 0, "%s %V",
33 30 tf->warn, &tf->file.name);
34 31 }
35 32 }
4 src/event/ngx_event.c
@@ -137,14 +137,14 @@ static ngx_command_t ngx_event_core_commands[] = {
137 137 NULL },
138 138
139 139 { ngx_string("multi_accept"),
140   - NGX_EVENT_CONF|NGX_CONF_TAKE1,
  140 + NGX_EVENT_CONF|NGX_CONF_FLAG,
141 141 ngx_conf_set_flag_slot,
142 142 0,
143 143 offsetof(ngx_event_conf_t, multi_accept),
144 144 NULL },
145 145
146 146 { ngx_string("accept_mutex"),
147   - NGX_EVENT_CONF|NGX_CONF_TAKE1,
  147 + NGX_EVENT_CONF|NGX_CONF_FLAG,
148 148 ngx_conf_set_flag_slot,
149 149 0,
150 150 offsetof(ngx_event_conf_t, accept_mutex),
2  src/http/modules/ngx_http_access_module.c
@@ -55,7 +55,7 @@ static ngx_command_t ngx_http_access_commands[] = {
55 55
56 56
57 57
58   -ngx_http_module_t ngx_http_access_module_ctx = {
  58 +static ngx_http_module_t ngx_http_access_module_ctx = {
59 59 NULL, /* preconfiguration */
60 60 NULL, /* postconfiguration */
61 61
4 src/http/modules/ngx_http_addition_filter_module.c
@@ -143,7 +143,7 @@ ngx_http_addition_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
143 143 ctx->before_body_sent = 1;
144 144
145 145 if (conf->before_body.len) {
146   - if (ngx_http_subrequest(r, &conf->before_body, NULL, 0)
  146 + if (ngx_http_subrequest(r, &conf->before_body, NULL, NULL, 0)
147 147 == NGX_ERROR)
148 148 {
149 149 return NGX_ERROR;
@@ -167,7 +167,7 @@ ngx_http_addition_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
167 167 return rc;
168 168 }
169 169
170   - if (ngx_http_subrequest(r, &conf->after_body, NULL, 0) == NGX_ERROR) {
  170 + if (ngx_http_subrequest(r, &conf->after_body, NULL, NULL, 0) == NGX_ERROR) {
171 171 return NGX_ERROR;
172 172 }
173 173
2  src/http/modules/ngx_http_auth_basic_module.c
@@ -60,7 +60,7 @@ static ngx_command_t ngx_http_auth_basic_commands[] = {
60 60 };
61 61
62 62
63   -ngx_http_module_t ngx_http_auth_basic_module_ctx = {
  63 +static ngx_http_module_t ngx_http_auth_basic_module_ctx = {
64 64 NULL, /* preconfiguration */
65 65 NULL, /* postconfiguration */
66 66
2  src/http/modules/ngx_http_autoindex_module.c
@@ -81,7 +81,7 @@ static ngx_command_t ngx_http_autoindex_commands[] = {
81 81 };
82 82
83 83
84   -ngx_http_module_t ngx_http_autoindex_module_ctx = {
  84 +static ngx_http_module_t ngx_http_autoindex_module_ctx = {
85 85 NULL, /* preconfiguration */
86 86 NULL, /* postconfiguration */
87 87
3  src/http/modules/ngx_http_charset_filter_module.c
@@ -1325,6 +1325,9 @@ ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
1325 1325
1326 1326 if (ngx_strcasecmp(name->data, "utf-8") == 0) {
1327 1327 c->utf8 = 1;
  1328 +
  1329 + } else {
  1330 + c->utf8 = 0;
1328 1331 }
1329 1332
1330 1333 return i;
7 src/http/modules/ngx_http_chunked_filter_module.c
@@ -95,8 +95,11 @@ ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
95 95
96 96 size += ngx_buf_size(cl->buf);
97 97
98   - if (cl->buf->flush || ngx_buf_in_memory(cl->buf) || cl->buf->in_file) {
99   -
  98 + if (cl->buf->flush
  99 + || cl->buf->sync
  100 + || ngx_buf_in_memory(cl->buf)
  101 + || cl->buf->in_file)
  102 + {
100 103 tl = ngx_alloc_chain_link(r->pool);
101 104 if (tl == NULL) {
102 105 return NGX_ERROR;
2  src/http/modules/ngx_http_dav_module.c
@@ -57,7 +57,7 @@ static ngx_command_t ngx_http_dav_commands[] = {
57 57 };
58 58
59 59
60   -ngx_http_module_t ngx_http_dav_module_ctx = {
  60 +static ngx_http_module_t ngx_http_dav_module_ctx = {
61 61 NULL, /* preconfiguration */
62 62 NULL, /* postconfiguration */
63 63
2  src/http/modules/ngx_http_empty_gif_module.c
@@ -74,7 +74,7 @@ static u_char ngx_empty_gif[] = {
74 74 };
75 75
76 76
77   -ngx_http_module_t ngx_http_empty_gif_module_ctx = {
  77 +static ngx_http_module_t ngx_http_empty_gif_module_ctx = {
78 78 NULL, /* preconfiguration */
79 79 NULL, /* postconfiguration */
80 80
2  src/http/modules/ngx_http_fastcgi_module.c
@@ -347,7 +347,7 @@ static ngx_command_t ngx_http_fastcgi_commands[] = {
347 347 };
348 348
349 349
350   -ngx_http_module_t ngx_http_fastcgi_module_ctx = {
  350 +static ngx_http_module_t ngx_http_fastcgi_module_ctx = {
351 351 ngx_http_fastcgi_add_variables, /* preconfiguration */
352 352 NULL, /* postconfiguration */
353 353
2  src/http/modules/ngx_http_index_module.c
@@ -72,7 +72,7 @@ static ngx_command_t ngx_http_index_commands[] = {
72 72 };
73 73
74 74
75   -ngx_http_module_t ngx_http_index_module_ctx = {
  75 +static ngx_http_module_t ngx_http_index_module_ctx = {
76 76 NULL, /* preconfiguration */
77 77 NULL, /* postconfiguration */
78 78
2  src/http/modules/ngx_http_log_module.c
@@ -142,7 +142,7 @@ static ngx_command_t ngx_http_log_commands[] = {
142 142 };
143 143
144 144
145   -ngx_http_module_t ngx_http_log_module_ctx = {
  145 +static ngx_http_module_t ngx_http_log_module_ctx = {
146 146 ngx_http_log_set_formats, /* preconfiguration */
147 147 ngx_http_log_init, /* postconfiguration */
148 148
2  src/http/modules/ngx_http_memcached_module.c
@@ -112,7 +112,7 @@ static ngx_command_t ngx_http_memcached_commands[] = {
112 112 };
113 113
114 114
115   -ngx_http_module_t ngx_http_memcached_module_ctx = {
  115 +static ngx_http_module_t ngx_http_memcached_module_ctx = {
116 116 NULL, /* preconfiguration */
117 117 NULL, /* postconfiguration */
118 118
2  src/http/modules/ngx_http_proxy_module.c
@@ -327,7 +327,7 @@ static ngx_command_t ngx_http_proxy_commands[] = {
327 327 };
328 328
329 329
330   -ngx_http_module_t ngx_http_proxy_module_ctx = {
  330 +static ngx_http_module_t ngx_http_proxy_module_ctx = {
331 331 ngx_http_proxy_add_variables, /* preconfiguration */
332 332 NULL, /* postconfiguration */
333 333
2  src/http/modules/ngx_http_realip_module.c
@@ -61,7 +61,7 @@ static ngx_command_t ngx_http_realip_commands[] = {
61 61
62 62
63 63
64   -ngx_http_module_t ngx_http_realip_module_ctx = {
  64 +static ngx_http_module_t ngx_http_realip_module_ctx = {
65 65 NULL, /* preconfiguration */
66 66 NULL, /* postconfiguration */
67 67
2  src/http/modules/ngx_http_rewrite_module.c
@@ -102,7 +102,7 @@ static ngx_command_t ngx_http_rewrite_commands[] = {
102 102 };
103 103
104 104
105   -ngx_http_module_t ngx_http_rewrite_module_ctx = {
  105 +static ngx_http_module_t ngx_http_rewrite_module_ctx = {
106 106 NULL, /* preconfiguration */
107 107 NULL, /* postconfiguration */
108 108
314 src/http/modules/ngx_http_ssi_filter_module.c
@@ -36,6 +36,13 @@ typedef struct {
36 36 } ngx_http_ssi_var_t;
37 37
38 38
  39 +typedef struct {
  40 + ngx_str_t name;
  41 + ngx_chain_t *bufs;
  42 + ngx_uint_t count;
  43 +} ngx_http_ssi_block_t;
  44 +
  45 +
39 46 typedef enum {
40 47 ssi_start_state = 0,
41 48 ssi_tag_state,
@@ -83,6 +90,10 @@ static ngx_int_t ngx_http_ssi_else(ngx_http_request_t *r,
83 90 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params);
84 91 static ngx_int_t ngx_http_ssi_endif(ngx_http_request_t *r,
85 92 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params);
  93 +static ngx_int_t ngx_http_ssi_block(ngx_http_request_t *r,
  94 + ngx_http_ssi_ctx_t *ctx, ngx_str_t **params);
  95 +static ngx_int_t ngx_http_ssi_endblock(ngx_http_request_t *r,
  96 + ngx_http_ssi_ctx_t *ctx, ngx_str_t **params);
86 97
87 98 static ngx_int_t ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r,
88 99 ngx_http_variable_value_t *v, uintptr_t gmt);
@@ -189,6 +200,7 @@ static ngx_str_t ngx_http_ssi_none = ngx_string("(none)");
189 200 #define NGX_HTTP_SSI_INCLUDE_VIRTUAL 0
190 201 #define NGX_HTTP_SSI_INCLUDE_FILE 1
191 202 #define NGX_HTTP_SSI_INCLUDE_WAIT 2
  203 +#define NGX_HTTP_SSI_INCLUDE_STUB 3
192 204
193 205 #define NGX_HTTP_SSI_ECHO_VAR 0
194 206 #define NGX_HTTP_SSI_ECHO_DEFAULT 1
@@ -201,11 +213,14 @@ static ngx_str_t ngx_http_ssi_none = ngx_string("(none)");
201 213
202 214 #define NGX_HTTP_SSI_IF_EXPR 0
203 215
  216 +#define NGX_HTTP_SSI_BLOCK_NAME 0
  217 +
204 218
205 219 static ngx_http_ssi_param_t ngx_http_ssi_include_params[] = {
206 220 { ngx_string("virtual"), NGX_HTTP_SSI_INCLUDE_VIRTUAL, 0, 0 },
207 221 { ngx_string("file"), NGX_HTTP_SSI_INCLUDE_FILE, 0, 0 },
208 222 { ngx_string("wait"), NGX_HTTP_SSI_INCLUDE_WAIT, 0, 0 },
  223 + { ngx_string("stub"), NGX_HTTP_SSI_INCLUDE_STUB, 0, 0 },
209 224 { ngx_null_string, 0, 0, 0 }
210 225 };
211 226
@@ -237,6 +252,12 @@ static ngx_http_ssi_param_t ngx_http_ssi_if_params[] = {
237 252 };
238 253
239 254
  255 +static ngx_http_ssi_param_t ngx_http_ssi_block_params[] = {
  256 + { ngx_string("name"), NGX_HTTP_SSI_BLOCK_NAME, 1, 0 },
  257 + { ngx_null_string, 0, 0, 0 }
  258 +};
  259 +
  260 +
240 261 static ngx_http_ssi_param_t ngx_http_ssi_no_params[] = {
241 262 { ngx_null_string, 0, 0, 0 }
242 263 };
@@ -244,21 +265,27 @@ static ngx_http_ssi_param_t ngx_http_ssi_no_params[] = {
244 265
245 266 static ngx_http_ssi_command_t ngx_http_ssi_commands[] = {
246 267 { ngx_string("include"), ngx_http_ssi_include,
247   - ngx_http_ssi_include_params, 0, 1 },
248   - { ngx_string("echo"), ngx_http_ssi_echo, ngx_http_ssi_echo_params, 0, 0 },
  268 + ngx_http_ssi_include_params, 0, 0, 1 },
  269 + { ngx_string("echo"), ngx_http_ssi_echo,
  270 + ngx_http_ssi_echo_params, 0, 0, 0 },
249 271 { ngx_string("config"), ngx_http_ssi_config,
250   - ngx_http_ssi_config_params, 0, 0 },
251   - { ngx_string("set"), ngx_http_ssi_set, ngx_http_ssi_set_params, 0, 0 },
  272 + ngx_http_ssi_config_params, 0, 0, 0 },
  273 + { ngx_string("set"), ngx_http_ssi_set, ngx_http_ssi_set_params, 0, 0, 0 },
252 274
253   - { ngx_string("if"), ngx_http_ssi_if, ngx_http_ssi_if_params, 0, 0 },
  275 + { ngx_string("if"), ngx_http_ssi_if, ngx_http_ssi_if_params, 0, 0, 0 },
254 276 { ngx_string("elif"), ngx_http_ssi_if, ngx_http_ssi_if_params,
255   - NGX_HTTP_SSI_COND_IF, 0 },
  277 + NGX_HTTP_SSI_COND_IF, 0, 0 },
256 278 { ngx_string("else"), ngx_http_ssi_else, ngx_http_ssi_no_params,
257   - NGX_HTTP_SSI_COND_IF, 0 },
  279 + NGX_HTTP_SSI_COND_IF, 0, 0 },
258 280 { ngx_string("endif"), ngx_http_ssi_endif, ngx_http_ssi_no_params,
259   - NGX_HTTP_SSI_COND_ELSE, 0 },
  281 + NGX_HTTP_SSI_COND_ELSE, 0, 0 },
  282 +
  283 + { ngx_string("block"), ngx_http_ssi_block,
  284 + ngx_http_ssi_block_params, 0, 0, 0 },
  285 + { ngx_string("endblock"), ngx_http_ssi_endblock,
  286 + ngx_http_ssi_no_params, 0, 1, 0 },
260 287
261   - { ngx_null_string, NULL, NULL, 0, 0 }
  288 + { ngx_null_string, NULL, NULL, 0, 0, 0 }
262 289 };
263 290
264 291
@@ -348,13 +375,15 @@ ngx_http_ssi_header_filter(ngx_http_request_t *r)
348 375 static ngx_int_t
349 376 ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
350 377 {
  378 + size_t len;
351 379 ngx_int_t rc;
352 380 ngx_buf_t *b;
353 381 ngx_uint_t i, index;
354   - ngx_chain_t *cl;
  382 + ngx_chain_t *cl, **ll;
355 383 ngx_table_elt_t *param;
356 384 ngx_connection_t *c;
357   - ngx_http_ssi_ctx_t *ctx;
  385 + ngx_http_ssi_ctx_t *ctx, *mctx;
  386 + ngx_http_ssi_block_t *bl;
358 387 ngx_http_ssi_param_t *prm;
359 388 ngx_http_ssi_command_t *cmd;
360 389 ngx_http_ssi_loc_conf_t *slcf;
@@ -510,6 +539,47 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
510 539 ctx->last_out = &cl->next;
511 540
512 541 } else {
  542 + if (ctx->block
  543 + && ctx->saved + (ctx->copy_end - ctx->copy_start))
  544 + {
  545 + b = ngx_create_temp_buf(r->pool,
  546 + ctx->saved + (ctx->copy_end - ctx->copy_start));
  547 +
  548 + if (b == NULL) {
  549 + return NGX_ERROR;
  550 + }
  551 +
  552 + if (ctx->saved) {
  553 + b->last = ngx_cpymem(b->pos, ngx_http_ssi_string,
  554 + ctx->saved);
  555 + }
  556 +
  557 + b->last = ngx_cpymem(b->last, ctx->copy_start,
  558 + ctx->copy_end - ctx->copy_start);
  559 +
  560 + cl = ngx_alloc_chain_link(r->pool);
  561 + if (cl == NULL) {
  562 + return NGX_ERROR;
  563 + }
  564 +
  565 + cl->buf = b;
  566 + cl->next = NULL;
  567 +
  568 + b = NULL;
  569 +
  570 + mctx = ngx_http_get_module_ctx(r->main,
  571 + ngx_http_ssi_filter_module);
  572 + bl = mctx->blocks->elts;
  573 + for (ll = &bl[mctx->blocks->nelts - 1].bufs;
  574 + *ll;
  575 + ll = &(*ll)->next)
  576 + {
  577 + /* void */
  578 + }
  579 +
  580 + *ll = cl;
  581 + }
  582 +
513 583 ctx->saved = 0;
514 584 }
515 585 }
@@ -559,8 +629,79 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
559 629 goto ssi_error;
560 630 }
561 631
562   - if (!ctx->output && cmd->conditional == 0) {
563   - continue;
  632 + if (!ctx->output && !cmd->block) {
  633 +
  634 + if (ctx->block) {
  635 +
  636 + /* reconstruct the SSI command text */
  637 +
  638 + len = 5 + ctx->command.len + 4;
  639 +
  640 + param = ctx->params.elts;
  641 + for (i = 0; i < ctx->params.nelts; i++) {
  642 + len += 1 + param[i].key.len + 2
  643 + + param[i].value.len + 1;
  644 + }
  645 +
  646 + b = ngx_create_temp_buf(r->pool, len);
  647 +
  648 + if (b == NULL) {
  649 + return NGX_ERROR;
  650 + }
  651 +
  652 + cl = ngx_alloc_chain_link(r->pool);
  653 + if (cl == NULL) {
  654 + return NGX_ERROR;
  655 + }
  656 +
  657 + cl->buf = b;
  658 + cl->next = NULL;
  659 +
  660 + *b->last++ = '<';
  661 + *b->last++ = '!';
  662 + *b->last++ = '-';
  663 + *b->last++ = '-';
  664 + *b->last++ = '#';
  665 +
  666 + b->last = ngx_cpymem(b->last, ctx->command.data,
  667 + ctx->command.len);
  668 +
  669 + for (i = 0; i < ctx->params.nelts; i++) {
  670 + *b->last++ = ' ';
  671 + b->last = ngx_cpymem(b->last, param[i].key.data,
  672 + param[i].key.len);
  673 + *b->last++ = '=';
  674 + *b->last++ = '"';
  675 + b->last = ngx_cpymem(b->last, param[i].value.data,
  676 + param[i].value.len);
  677 + *b->last++ = '"';
  678 + }
  679 +
  680 + *b->last++ = ' ';
  681 + *b->last++ = '-';
  682 + *b->last++ = '-';
  683 + *b->last++ = '>';
  684 +
  685 + mctx = ngx_http_get_module_ctx(r->main,
  686 + ngx_http_ssi_filter_module);
  687 + bl = mctx->blocks->elts;
  688 + for (ll = &bl[mctx->blocks->nelts - 1].bufs;
  689 + *ll;
  690 + ll = &(*ll)->next)
  691 + {
  692 + /* void */
  693 + }
  694 +
  695 + *ll = cl;
  696 +
  697 + b = NULL;
  698 +
  699 + continue;
  700 + }
  701 +
  702 + if (cmd->conditional == 0) {
  703 + continue;
  704 + }
564 705 }
565 706
566 707 if (ctx->params.nelts > NGX_HTTP_SSI_MAX_PARAMS) {
@@ -1382,8 +1523,12 @@ ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name,
1382 1523
1383 1524 ctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module);
1384 1525
1385   - var = ctx->variables.elts;
1386   - for (i = 0; i < ctx->variables.nelts; i++) {
  1526 + if (ctx->variables == NULL) {
  1527 + return NULL;
  1528 + }
  1529 +
  1530 + var = ctx->variables->elts;
  1531 + for (i = 0; i < ctx->variables->nelts; i++) {
1387 1532 if (name->len != var[i].name.len) {
1388 1533 continue;
1389 1534 }
@@ -1663,13 +1808,18 @@ static ngx_int_t
1663 1808 ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1664 1809 ngx_str_t **params)
1665 1810 {
1666   - ngx_int_t rc;
1667   - ngx_str_t *uri, *file, *wait, args;
1668   - ngx_uint_t flags;
  1811 + ngx_int_t rc;
  1812 + ngx_str_t *uri, *file, *wait, *stub, args;
  1813 + ngx_buf_t *b;
  1814 + ngx_uint_t flags, i;
  1815 + ngx_chain_t *out, *cl, *tl, **ll;
  1816 + ngx_http_ssi_ctx_t *mctx;
  1817 + ngx_http_ssi_block_t *bl;
1669 1818
1670 1819 uri = params[NGX_HTTP_SSI_INCLUDE_VIRTUAL];
1671 1820 file = params[NGX_HTTP_SSI_INCLUDE_FILE];
1672 1821 wait = params[NGX_HTTP_SSI_INCLUDE_WAIT];
  1822 + stub = params[NGX_HTTP_SSI_INCLUDE_STUB];
1673 1823
1674 1824 if (uri && file) {
1675 1825 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
@@ -1687,8 +1837,7 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1687 1837 if (wait) {
1688 1838 if (uri == NULL) {
1689 1839 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1690   - "\"wait\" may not be used with file=\"%V\"",
1691   - uri, file);
  1840 + "\"wait\" may not be used with file=\"%V\"", file);
1692 1841 return NGX_HTTP_SSI_ERROR;
1693 1842 }
1694 1843
@@ -1699,7 +1848,7 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1699 1848 {
1700 1849 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1701 1850 "invalid value \"%V\" in the \"wait\" parameter",
1702   - &wait);
  1851 + wait);
1703 1852 return NGX_HTTP_SSI_ERROR;
1704 1853 }
1705 1854 }
@@ -1725,7 +1874,68 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1725 1874 return NGX_HTTP_SSI_ERROR;
1726 1875 }
1727 1876
1728   - rc = ngx_http_subrequest(r, uri, &args, flags);
  1877 + out = NULL;
  1878 +
  1879 + if (stub) {
  1880 + mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module);
  1881 +
  1882 + if (mctx->blocks) {
  1883 + bl = mctx->blocks->elts;
  1884 + for (i = 0; i < mctx->blocks->nelts; i++) {
  1885 + if (stub->len == bl[i].name.len
  1886 + && ngx_strncmp(stub->data, bl[i].name.data, stub->len) == 0)
  1887 + {
  1888 + goto found;
  1889 + }
  1890 + }
  1891 + }
  1892 +
  1893 + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
  1894 + "\"stub\"=\"%V\" for \"include\" not found", stub);
  1895 + return NGX_HTTP_SSI_ERROR;
  1896 +
  1897 + found:
  1898 +
  1899 + if (bl[i].count++) {
  1900 +
  1901 + ll = &out;
  1902 +
  1903 + for (tl = bl[i].bufs; tl; tl = tl->next) {
  1904 +
  1905 + if (ctx->free) {
  1906 + cl = ctx->free;
  1907 + ctx->free = ctx->free->next;
  1908 + b = cl->buf;
  1909 +
  1910 + } else {
  1911 + b = ngx_alloc_buf(r->pool);
  1912 + if (b == NULL) {
  1913 + return NGX_ERROR;
  1914 + }
  1915 +
  1916 + cl = ngx_alloc_chain_link(r->pool);
  1917 + if (cl == NULL) {
  1918 + return NGX_ERROR;
  1919 + }
  1920 +
  1921 + cl->buf = b;
  1922 + }
  1923 +
  1924 + ngx_memcpy(b, tl->buf, sizeof(ngx_buf_t));
  1925 +
  1926 + b->pos = b->start;
  1927 +
  1928 + *ll = cl;
  1929 + cl->next = NULL;
  1930 + ll = &cl->next;
  1931 + }
  1932 +
  1933 + } else {
  1934 + out = bl[i].bufs;
  1935 + }
  1936 + }
  1937 +
  1938 + rc = ngx_http_subrequest(r, uri, &args, out, flags);
1729 1939
1730 1940 if (rc == NGX_ERROR) {
1731 1941 return NGX_HTTP_SSI_ERROR;
@@ -1861,10 +2071,10 @@ ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1861 2071
1862 2072 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module);
1863 2073
1864   - if (mctx->variables.elts == NULL) {
1865   - if (ngx_array_init(&mctx->variables, r->pool, 4,
1866   - sizeof(ngx_http_ssi_var_t)) != NGX_OK)
1867   - {
  2074 + if (mctx->variables == NULL) {
  2075 + mctx->variables = ngx_array_create(r->pool, 4,
  2076 + sizeof(ngx_http_ssi_var_t));
  2077 + if (mctx->variables == NULL) {
1868 2078 return NGX_HTTP_SSI_ERROR;
1869 2079 }
1870 2080 }
@@ -1893,7 +2103,7 @@ ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
1893 2103 return NGX_OK;
1894 2104 }
1895 2105
1896   - var = ngx_array_push(&mctx->variables);
  2106 + var = ngx_array_push(mctx->variables);
1897 2107 if (var == NULL) {
1898 2108 return NGX_HTTP_SSI_ERROR;
1899 2109 }
@@ -2136,6 +2346,56 @@ ngx_http_ssi_endif(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
2136 2346
2137 2347
2138 2348 static ngx_int_t
  2349 +ngx_http_ssi_block(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
  2350 + ngx_str_t **params)
  2351 +{
  2352 + ngx_http_ssi_ctx_t *mctx;
  2353 + ngx_http_ssi_block_t *bl;
  2354 +
  2355 + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
  2356 + "ssi block");
  2357 +
  2358 + mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module);
  2359 +
  2360 + if (mctx->blocks == NULL) {
  2361 + mctx->blocks = ngx_array_create(r->pool, 4,
  2362 + sizeof(ngx_http_ssi_block_t));
  2363 + if (mctx->blocks == NULL) {
  2364 + return NGX_HTTP_SSI_ERROR;
  2365 + }
  2366 + }
  2367 +