Fixed failure to start cache manager and cache loader processes
if there were more than 512 listening sockets in configuration.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4918 73f98a42-aea0-e011-b76d-00259023448c
Dav: fixed segfault on PUT if body was already read (ticket #238).

If request body reading happens with different options it's possible
that there will be no r->request_body->temp_file available (or even
no r->request_body available if body was discarded).  Return internal
server error in this case instead of committing suicide by dereferencing
a null pointer.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4919 73f98a42-aea0-e011-b76d-00259023448c
Core: added debug logging of writev() in ngx_write_chain_to_file().


git-svn-id: svn://svn.nginx.org/nginx/trunk@4920 73f98a42-aea0-e011-b76d-00259023448c
Request body: fixed "501 Not Implemented" error handling.

It is not about "Method" but a generic message, and is expected to be used
e.g. if specified Transfer-Encoding is not supported.  Fixed message to
match RFC 2616.

Additionally, disable keepalive on such errors as we won't be able to read
request body correctly if we don't understand Transfer-Encoding used.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4921 73f98a42-aea0-e011-b76d-00259023448c
Request body: $request_body variable generalization.

The $request_body variable was assuming there can't be more than two
buffers.  While this is currently true due to request body reading
implementation details, this is not a good thing to depend on and may
change in the future.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4922 73f98a42-aea0-e011-b76d-00259023448c
Request body: code duplication reduced, no functional changes.

The r->request_body_in_file_only with empty body case is now handled in
ngx_http_write_request_body().


git-svn-id: svn://svn.nginx.org/nginx/trunk@4923 73f98a42-aea0-e011-b76d-00259023448c
Request body: fixed socket leak on errors.

The r->main->count reference counter was always incremented in
ngx_http_read_client_request_body(), while it is only needs to be
incremented on positive returns.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4924 73f98a42-aea0-e011-b76d-00259023448c
Request body: properly handle events while discarding body.

An attempt to call ngx_handle_read_event() before actually reading
data from a socket might result in read event being disabled, which is
wrong.  Catched by body.t test on Solaris.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4925 73f98a42-aea0-e011-b76d-00259023448c
Request body: chunked parsing moved to ngx_http_parse.c from proxy.

No functional changes.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4926 73f98a42-aea0-e011-b76d-00259023448c
Request body: adjust b->pos when chunked parsing done.

This is a nop for the current code, though will allow to correctly parse
pipelined requests.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4927 73f98a42-aea0-e011-b76d-00259023448c
Request body: always use calculated size of a request body in proxy.

This allows to handle requests with chunked body, and also simplifies
handling of various request body modifications.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4928 73f98a42-aea0-e011-b76d-00259023448c
Request body: $content_length variable to honor real body size.

This allows to handle requests with chunked body by fastcgi and uwsgi
modules, and also simplifies handling of various request body modifications.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4929 73f98a42-aea0-e011-b76d-00259023448c
Request body: recalculate size of a request body in scgi module.

This allows to handle requests with chunked body by scgi module, and
also simplifies handling of various request body modifications.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4930 73f98a42-aea0-e011-b76d-00259023448c
Request body: chunked transfer encoding support.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4931 73f98a42-aea0-e011-b76d-00259023448c
Request body: unbreak build without debug.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4932 73f98a42-aea0-e011-b76d-00259023448c
Fixed location of debug message in ngx_shmtx_lock().


git-svn-id: svn://svn.nginx.org/nginx/trunk@4933 73f98a42-aea0-e011-b76d-00259023448c
Core: don't reuse shared memory zone that changed ownership (ticket #210).

nginx doesn't allow the same shared memory zone to be used for different
purposes, but failed to check this on reconfiguration.  If a shared memory
zone was used for another purpose in the new configuration, nginx attempted
to reuse it and crashed.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4934 73f98a42-aea0-e011-b76d-00259023448c
Request body: fixed discard of chunked request body.

Even if there is no preread data, make sure to always call
ngx_http_discard_request_body_filter() in case of chunked request
body to initialize r->headers_in.content_length_n for later use.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4935 73f98a42-aea0-e011-b76d-00259023448c
Request body: improved handling of incorrect chunked request body.

While discarding chunked request body in some cases after detecting
request body corruption no error was returned, while it was possible
to correctly return 400 Bad Request.  If error is detected too late,
make sure to properly close connection.

Additionally, in ngx_http_special_response_handler() don't return body
of 500 Internal Server Error to a client if ngx_http_discard_request_body()
fails, but disable keepalive and continue.


git-svn-id: svn://svn.nginx.org/nginx/trunk@4936 73f98a42-aea0-e011-b76d-00259023448c
Request body: error checking fixes, negative rb->rest handling.

Negative rb->rest can't happen with current code, but it's good to have
it handled anyway.

Found by Coverity (CID 744846, 744847, 744848).


git-svn-id: svn://svn.nginx.org/nginx/trunk@4937 73f98a42-aea0-e011-b76d-00259023448c