# HG changeset patch # User Igor Sysoev # Date 1080317581 0 # Node ID bfe099e3f5b47e040c478f2ff39c19916074c855 # Parent 99b349386504cc2b83cc6dc762d9b0af998aa1ba nginx-0.0.3-2004-03-26-19:13:01 import diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -228,7 +228,7 @@ struct ngx_http_request_s { ngx_temp_file_t *temp_file; ngx_chain_t *request_hunks; ngx_hunk_t *request_body_hunk; - size_t request_body_len; + size_t remaining_body_len; void (*request_body_handler) (void *data); void *data; diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c --- a/src/http/ngx_http_request_body.c +++ b/src/http/ngx_http_request_body.c @@ -19,6 +19,9 @@ ngx_int_t ngx_http_read_client_request_b size = r->header_in->last - r->header_in->pos; if (size) { + + /* there is the pre-read part of the request body */ + ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; @@ -28,19 +31,23 @@ ngx_int_t ngx_http_read_client_request_b ngx_alloc_link_and_set_hunk(r->request_hunks, h, r->pool, NGX_ERROR); if (size >= r->headers_in.content_length_n) { + + /* the whole request body was pre-read */ + r->header_in->pos += r->headers_in.content_length_n; - return NGX_OK; } r->header_in->pos = r->header_in->last; } - r->request_body_len = r->headers_in.content_length_n - size; + + r->remaining_body_len = r->headers_in.content_length_n - size; - if (r->request_body_len < request_buffer_size + (request_buffer_size >> 2)) + if (r->remaining_body_len + < request_buffer_size + (request_buffer_size >> 2)) { - size = r->request_body_len; + size = r->remaining_body_len; } else { size = request_buffer_size; @@ -116,8 +123,8 @@ static ngx_int_t ngx_http_do_read_client size = r->request_body_hunk->end - r->request_body_hunk->last; - if (size > r->request_body_len) { - size = r->request_body_len; + if (size > r->remaining_body_len) { + size = r->remaining_body_len; } n = ngx_recv(c, r->request_body_hunk->last, size); @@ -147,9 +154,9 @@ static ngx_int_t ngx_http_do_read_client } r->request_body_hunk->last += n; - r->request_body_len -= n; + r->remaining_body_len -= n; - if (r->request_body_len == 0) { + if (r->remaining_body_len == 0) { break; } @@ -160,9 +167,9 @@ static ngx_int_t ngx_http_do_read_client ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http client request body left " SIZE_T_FMT, - r->request_body_len); + r->remaining_body_len); - if (r->request_body_len) { + if (r->remaining_body_len) { return NGX_AGAIN; }