Merge of r4968, r4969, r4977, r4980, r4981, r4990: geo fixes.

*) Geo: improved ngx_http_geo_block() code readability.

*) Geo: fixed the "ranges" without ranges case.  The following
   configuration returned an empty value for $geo:

       geo $geo {
           ranges;
           default default;
       }

*) Fixed return type of internal function that allocates radix tree nodes.

*) There's no need to normalize address returned by ngx_ptocidr().

*) Geo: ensure that default entry is always present.  If 0.0.0.0/32 entry
   was present and there was no explicit "default", we failed to add an
   empty string as a default value.

*) Trailing whitespace fix.


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5048 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4993, r4994, r4997, r5000: geo ipv6 support.

*) Geo: IPv6 support.  The "ranges" mode is still limited to IPv4 only.

*) Geo: properly initialize ngx_cidr_t when dealing with "default".

*) Geo: made "default" affect both IPv4 and IPv6 when using prefixes.
   Previously, "default" was equivalent to specifying 0.0.0.0/0, now
   it's equivalent to specifying both 0.0.0.0/0 and ::/0 (if support
   for IPv6 is enabled) with the same value.

*) Geo: improved code readability.


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5049 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4974: avoid sending "100 Continue" on 413. 

Avoid sending "100 Continue" on 413 Request Entity Too Large.

Patch by Igor Sysoev.


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5050 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4983: crypt_r() error handling fixed.

The crypt_r() function returns NULL on errors, check it explicitly instead
of assuming errno will remain 0 if there are no errors (per POSIX, the
setting of errno after a successful call to a function is unspecified
unless the description of that function specifies that errno shall not
be modified).

Additionally, dropped unneeded ngx_set_errno(0) and fixed error handling
of memory allocation after normal crypt(), which was inapropriate and
resulted in null pointer dereference on allocation failures.


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5051 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4976: let add_header affect 201 responses (ticket #125).


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5052 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4979, r4982: image filter configuration inheritance.

*) Image filter: configuration inheritance fixes.

   The image_filter_jpeg_quality, image_filter_sharpen and
   "image_filter rotate" were inherited incorrectly if a directive
   with variables was defined, and then redefined to a literal value,
   i.e. in configurations like

       image_filter_jpeg_quality $arg_q;

       location / {
           image_filter_jpeg_quality 50;
       }

   Patch by Ian Babrou, with minor changes.

*) Image filter: fixed image_filter rotate inheritance.

   Configurations like

       location /i/ {
           image_filter resize 200 200;
           image_filter rotate 180;

           location /i/foo/ {
               image_filter resize 200 200;
           }
      }

   resulted in rotation incorrectly applied in the location /i/foo,
   without any way to clear it.  Fix is to handle conf->angle/conf->acv
   consistently with other filter variables and do not try to inherit
   them if there are transformations defined for current location.


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5053 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4985, r4986, r4987, r4988, r4989, r5002: access_log gzip.

*) Access log: fixed redundant buffer reallocation.  Previously a new
   buffer was allocated for every "access_log" directive with the same
   file path and "buffer=" parameters, while only one buffer per file
   is used.

*) Reopening log files code moved to a separate function.  The code
   refactored in a way to call custom handler that can do appropriate
   cleanup work (if any), like flushing buffers, finishing compress
   streams, finalizing connections to log daemon, etc..

*) Access log: the "flush" parameter of the "access_log" directive.

*) Configure: added the NGX_ZLIB define.  This was introduced for
   conditional compilation of the code that requires the zlib library.

*) Access log: the "gzip" parameter of the "access_log" directive.
   Note: this requires zlib version 1.2.0.4 or above to work.

*) The data pointer in ngx_open_file_t objects must be initialized.
   Uninitialized pointer may result in arbitrary segfaults if access_log
   is used without buffer and without variables in file path.
   Patch by Tatsuhiko Kubo (ticket #268).


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5054 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4991: fixed proxied HEAD requests with gzip enabled.

Fixed HEAD requests handling when proxying is used (ticket #261).


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5055 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4992: off-by-one with 32/64 upstream backup servers.

Fixed off-by-one during upstream state resetting when switching to
backup servers if there were exactly 32 (64 on 64-bit platforms)
backup servers configured.

Based on patch by Thomas Chen (ticket #257).


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5056 73f98a42-aea0-e011-b76d-00259023448c
Merge of r4999, r5003: detect duplicate "events" and "keepalive".

*) Upstream keepalive: detect duplicate "keepalive" directive.  A
   failure to detect duplicate "keepalive" directive resulted in
   stack exhaustion.

*) Events: added check for duplicate "events" directive.


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5057 73f98a42-aea0-e011-b76d-00259023448c
Merge of r5001: year 2013.


git-svn-id: svn://svn.nginx.org/nginx/branches/stable-1.2@5058 73f98a42-aea0-e011-b76d-00259023448c