Mercurial > hg > nginx-quic
comparison src/http/ngx_http_request_body.c @ 663:6d5c1535bb9d release-0.3.53
nginx-0.3.53-RELEASE import
*) Change: the "add_header" directive adds the string to 204, 301, and
302 responses.
*) Feature: the "server" directive in the "upstream" context supports
the "weight" parameter.
*) Feature: the "server_name" directive supports the "*" wildcard.
*) Feature: nginx supports the request body size more than 2G.
*) Bugfix: if a client was successfully authorized using "satisfy_any
on", then anyway the message "access forbidden by rule" was written
in the log.
*) Bugfix: the "PUT" method may erroneously not create a file and
return the 409 code.
*) Bugfix: if the IMAP/POP3 backend returned an error, then nginx
continued proxying anyway.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 07 Jul 2006 16:33:19 +0000 |
parents | e60fe4cf1d4e |
children | 5fd7a5e99047 |
comparison
equal
deleted
inserted
replaced
662:4c15f63afe65 | 663:6d5c1535bb9d |
---|---|
28 | 28 |
29 ngx_int_t | 29 ngx_int_t |
30 ngx_http_read_client_request_body(ngx_http_request_t *r, | 30 ngx_http_read_client_request_body(ngx_http_request_t *r, |
31 ngx_http_client_body_handler_pt post_handler) | 31 ngx_http_client_body_handler_pt post_handler) |
32 { | 32 { |
33 ssize_t size, preread; | 33 size_t preread; |
34 ssize_t size; | |
34 ngx_buf_t *b; | 35 ngx_buf_t *b; |
35 ngx_chain_t *cl, **next; | 36 ngx_chain_t *cl, **next; |
36 ngx_http_request_body_t *rb; | 37 ngx_http_request_body_t *rb; |
37 ngx_http_core_loc_conf_t *clcf; | 38 ngx_http_core_loc_conf_t *clcf; |
38 | 39 |
93 | 94 |
94 if (preread >= r->headers_in.content_length_n) { | 95 if (preread >= r->headers_in.content_length_n) { |
95 | 96 |
96 /* the whole request body was pre-read */ | 97 /* the whole request body was pre-read */ |
97 | 98 |
98 r->header_in->pos += r->headers_in.content_length_n; | 99 r->header_in->pos += (size_t) r->headers_in.content_length_n; |
99 r->request_length += r->headers_in.content_length_n; | 100 r->request_length += r->headers_in.content_length_n; |
100 | 101 |
101 if (r->request_body_in_file_only) { | 102 if (r->request_body_in_file_only) { |
102 if (ngx_http_write_request_body(r, rb->bufs) != NGX_OK) { | 103 if (ngx_http_write_request_body(r, rb->bufs) != NGX_OK) { |
103 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 104 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
141 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 142 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
142 | 143 |
143 size = clcf->client_body_buffer_size; | 144 size = clcf->client_body_buffer_size; |
144 size += size >> 2; | 145 size += size >> 2; |
145 | 146 |
146 if (rb->rest < (size_t) size) { | 147 if (rb->rest < size) { |
147 size = rb->rest; | 148 size = (ssize_t) rb->rest; |
148 | 149 |
149 if (r->request_body_in_single_buf) { | 150 if (r->request_body_in_single_buf) { |
150 size += preread; | 151 size += preread; |
151 } | 152 } |
152 | 153 |
240 } | 241 } |
241 | 242 |
242 size = rb->buf->end - rb->buf->last; | 243 size = rb->buf->end - rb->buf->last; |
243 | 244 |
244 if (size > rb->rest) { | 245 if (size > rb->rest) { |
245 size = rb->rest; | 246 size = (size_t) rb->rest; |
246 } | 247 } |
247 | 248 |
248 n = c->recv(c, rb->buf->last, size); | 249 n = c->recv(c, rb->buf->last, size); |
249 | 250 |
250 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 251 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
427 if (size) { | 428 if (size) { |
428 if (r->headers_in.content_length_n > size) { | 429 if (r->headers_in.content_length_n > size) { |
429 r->headers_in.content_length_n -= size; | 430 r->headers_in.content_length_n -= size; |
430 | 431 |
431 } else { | 432 } else { |
432 r->header_in->pos += r->headers_in.content_length_n; | 433 r->header_in->pos += (size_t) r->headers_in.content_length_n; |
433 r->headers_in.content_length_n = 0; | 434 r->headers_in.content_length_n = 0; |
434 return NGX_OK; | 435 return NGX_OK; |
435 } | 436 } |
436 } | 437 } |
437 | 438 |
466 | 467 |
467 | 468 |
468 static ngx_int_t | 469 static ngx_int_t |
469 ngx_http_read_discarded_body(ngx_http_request_t *r) | 470 ngx_http_read_discarded_body(ngx_http_request_t *r) |
470 { | 471 { |
471 ssize_t size, n; | 472 size_t size; |
473 ssize_t n; | |
472 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE]; | 474 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE]; |
473 | 475 |
474 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 476 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
475 "http read discarded body"); | 477 "http read discarded body"); |
476 | 478 |
477 if (r->headers_in.content_length_n == 0) { | 479 if (r->headers_in.content_length_n == 0) { |
478 return NGX_OK; | 480 return NGX_OK; |
479 } | 481 } |
480 | 482 |
481 | 483 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ? |
482 size = r->headers_in.content_length_n; | 484 NGX_HTTP_DISCARD_BUFFER_SIZE: |
483 | 485 (size_t) r->headers_in.content_length_n; |
484 if (size > NGX_HTTP_DISCARD_BUFFER_SIZE) { | |
485 size = NGX_HTTP_DISCARD_BUFFER_SIZE; | |
486 } | |
487 | 486 |
488 n = r->connection->recv(r->connection, buffer, size); | 487 n = r->connection->recv(r->connection, buffer, size); |
489 | 488 |
490 if (n == NGX_ERROR) { | 489 if (n == NGX_ERROR) { |
491 | 490 |