Mercurial > hg > nginx
comparison src/http/ngx_http_request_body.c @ 6496:887cca40ba6a
HTTP/2: rewritten handling of request body.
There are two improvements:
1. Support for request body filters;
2. Receiving of request body is started only after
the ngx_http_read_client_request_body() call.
The last one fixes the problem when the client_max_body_size value might not be
respected from the right location if the location was changed either during the
process of receiving body or after the whole body had been received.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 01 Apr 2016 15:56:03 +0300 |
parents | 3b9fe734a76c |
children | 9d66d7ed2abb |
comparison
equal
deleted
inserted
replaced
6495:92464ebace8e | 6496:887cca40ba6a |
---|---|
38 ngx_http_request_body_t *rb; | 38 ngx_http_request_body_t *rb; |
39 ngx_http_core_loc_conf_t *clcf; | 39 ngx_http_core_loc_conf_t *clcf; |
40 | 40 |
41 r->main->count++; | 41 r->main->count++; |
42 | 42 |
43 if (r != r->main || r->request_body || r->discard_body) { | |
44 r->request_body_no_buffering = 0; | |
45 post_handler(r); | |
46 return NGX_OK; | |
47 } | |
48 | |
43 #if (NGX_HTTP_V2) | 49 #if (NGX_HTTP_V2) |
44 if (r->stream && r == r->main) { | 50 if (r->stream) { |
45 r->request_body_no_buffering = 0; | 51 r->request_body_no_buffering = 0; |
46 rc = ngx_http_v2_read_request_body(r, post_handler); | 52 rc = ngx_http_v2_read_request_body(r, post_handler); |
47 goto done; | 53 goto done; |
48 } | 54 } |
49 #endif | 55 #endif |
50 | |
51 if (r != r->main || r->request_body || r->discard_body) { | |
52 r->request_body_no_buffering = 0; | |
53 post_handler(r); | |
54 return NGX_OK; | |
55 } | |
56 | 56 |
57 if (ngx_http_test_expect(r) != NGX_OK) { | 57 if (ngx_http_test_expect(r) != NGX_OK) { |
58 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; | 58 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; |
59 goto done; | 59 goto done; |
60 } | 60 } |
501 { | 501 { |
502 ssize_t size; | 502 ssize_t size; |
503 ngx_int_t rc; | 503 ngx_int_t rc; |
504 ngx_event_t *rev; | 504 ngx_event_t *rev; |
505 | 505 |
506 if (r != r->main || r->discard_body || r->request_body) { | |
507 return NGX_OK; | |
508 } | |
509 | |
506 #if (NGX_HTTP_V2) | 510 #if (NGX_HTTP_V2) |
507 if (r->stream && r == r->main) { | 511 if (r->stream) { |
508 r->stream->skip_data = NGX_HTTP_V2_DATA_DISCARD; | 512 r->stream->skip_data = 1; |
509 return NGX_OK; | 513 return NGX_OK; |
510 } | 514 } |
511 #endif | 515 #endif |
512 | |
513 if (r != r->main || r->discard_body || r->request_body) { | |
514 return NGX_OK; | |
515 } | |
516 | 516 |
517 if (ngx_http_test_expect(r) != NGX_OK) { | 517 if (ngx_http_test_expect(r) != NGX_OK) { |
518 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 518 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
519 } | 519 } |
520 | 520 |