I do not know if it is a bug or design intention: if request body client
sent is larger than the amount Content-Length specified . The addition
data
is also received and dealt in an incorrect way.
If content-length is smaller :
-
sending a PUT request to webdav module, addition data is written also
in
to file. -
proxy module behave wrongly, it closes client connection.
To avoid such problems:
@@ -1,4 +1,3 @@
/*
-
Copyright © Igor S.
*/
@@ -133,9 +132,12 @@ ngx_http_read_client_request_body(ngx_ht
rb->buf = b;if ((off_t) preread >= r->headers_in.content_length_n) {
-
/* the whole request body was pre-read */
-
b->last = b->pos + r->headers_in.content_length_n;
-
preread = r->headers_in.content_length_n;
-
r->header_in->pos += (size_t)
r->headers_in.content_length_n;
r->request_length += r->headers_in.content_length_n;
@@ -267,8 +269,17 @@ ngx_http_do_read_client_request_body(ngx
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
“http read client request body”);
- for ( ;; ) {
-
for ( ;; ) {
-
if (rb->rest == 0) {
-
/* dicard */
-
char buf[1024];
-
n = 1;
-
while (n > 0)
-
n = c->recv(c, buf, 1024);
-
return NGX_OK;
-
}
-
for ( ;rb->rest != 0; ) { if (rb->buf->last == rb->buf->end) { if (ngx_http_write_request_body(r, rb->to_write) !=
NGX_OK)
{