mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 14:13:33 -06:00
nginx-0.0.3-2004-03-26-19:13:01 import
This commit is contained in:
parent
32769a772c
commit
14f02ed0dd
@ -228,7 +228,7 @@ struct ngx_http_request_s {
|
|||||||
ngx_temp_file_t *temp_file;
|
ngx_temp_file_t *temp_file;
|
||||||
ngx_chain_t *request_hunks;
|
ngx_chain_t *request_hunks;
|
||||||
ngx_hunk_t *request_body_hunk;
|
ngx_hunk_t *request_body_hunk;
|
||||||
size_t request_body_len;
|
size_t remaining_body_len;
|
||||||
void (*request_body_handler) (void *data);
|
void (*request_body_handler) (void *data);
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
|||||||
size = r->header_in->last - r->header_in->pos;
|
size = r->header_in->last - r->header_in->pos;
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
|
|
||||||
|
/* there is the pre-read part of the request body */
|
||||||
|
|
||||||
ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
|
ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
|
||||||
|
|
||||||
h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
|
h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
|
||||||
@ -28,19 +31,23 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
|||||||
ngx_alloc_link_and_set_hunk(r->request_hunks, h, r->pool, NGX_ERROR);
|
ngx_alloc_link_and_set_hunk(r->request_hunks, h, r->pool, NGX_ERROR);
|
||||||
|
|
||||||
if (size >= r->headers_in.content_length_n) {
|
if (size >= r->headers_in.content_length_n) {
|
||||||
r->header_in->pos += 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;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->header_in->pos = r->header_in->last;
|
r->header_in->pos = r->header_in->last;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->request_body_len = r->headers_in.content_length_n - size;
|
|
||||||
|
|
||||||
if (r->request_body_len < request_buffer_size + (request_buffer_size >> 2))
|
r->remaining_body_len = r->headers_in.content_length_n - size;
|
||||||
|
|
||||||
|
if (r->remaining_body_len
|
||||||
|
< request_buffer_size + (request_buffer_size >> 2))
|
||||||
{
|
{
|
||||||
size = r->request_body_len;
|
size = r->remaining_body_len;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
size = request_buffer_size;
|
size = request_buffer_size;
|
||||||
@ -116,8 +123,8 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r)
|
|||||||
|
|
||||||
size = r->request_body_hunk->end - r->request_body_hunk->last;
|
size = r->request_body_hunk->end - r->request_body_hunk->last;
|
||||||
|
|
||||||
if (size > r->request_body_len) {
|
if (size > r->remaining_body_len) {
|
||||||
size = r->request_body_len;
|
size = r->remaining_body_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = ngx_recv(c, r->request_body_hunk->last, size);
|
n = ngx_recv(c, r->request_body_hunk->last, size);
|
||||||
@ -147,9 +154,9 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
r->request_body_hunk->last += n;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,9 +167,9 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r)
|
|||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||||
"http client request body left " SIZE_T_FMT,
|
"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;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user