comparison src/http/ngx_http_request_body.c @ 6989:2c4dbcd6f2e4

HTTP/2: reduced difference to HTTP/1.x in reading request body. Particularly, this eliminates difference in behavior for requests without body and deduplicates code. Prodded by Piotr Sikora.
author Valentin Bartenev <vbart@nginx.com>
date Mon, 24 Apr 2017 14:17:13 +0300
parents 5e2423bce883
children 08ff2e10ae92 5649079a41f4
comparison
equal deleted inserted replaced
6988:cc823122d50d 6989:2c4dbcd6f2e4
43 if (r != r->main || r->request_body || r->discard_body) { 43 if (r != r->main || r->request_body || r->discard_body) {
44 r->request_body_no_buffering = 0; 44 r->request_body_no_buffering = 0;
45 post_handler(r); 45 post_handler(r);
46 return NGX_OK; 46 return NGX_OK;
47 } 47 }
48
49 #if (NGX_HTTP_V2)
50 if (r->stream) {
51 rc = ngx_http_v2_read_request_body(r, post_handler);
52 goto done;
53 }
54 #endif
55 48
56 if (ngx_http_test_expect(r) != NGX_OK) { 49 if (ngx_http_test_expect(r) != NGX_OK) {
57 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; 50 rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
58 goto done; 51 goto done;
59 } 52 }
83 r->request_body_no_buffering = 0; 76 r->request_body_no_buffering = 0;
84 post_handler(r); 77 post_handler(r);
85 return NGX_OK; 78 return NGX_OK;
86 } 79 }
87 80
81 #if (NGX_HTTP_V2)
82 if (r->stream) {
83 rc = ngx_http_v2_read_request_body(r);
84 goto done;
85 }
86 #endif
87
88 preread = r->header_in->last - r->header_in->pos; 88 preread = r->header_in->last - r->header_in->pos;
89 89
90 if (preread) { 90 if (preread) {
91 91
92 /* there is the pre-read part of the request body */ 92 /* there is the pre-read part of the request body */
803 ngx_int_t n; 803 ngx_int_t n;
804 ngx_str_t *expect; 804 ngx_str_t *expect;
805 805
806 if (r->expect_tested 806 if (r->expect_tested
807 || r->headers_in.expect == NULL 807 || r->headers_in.expect == NULL
808 || r->http_version < NGX_HTTP_VERSION_11) 808 || r->http_version < NGX_HTTP_VERSION_11
809 #if (NGX_HTTP_V2)
810 || r->stream != NULL
811 #endif
812 )
809 { 813 {
810 return NGX_OK; 814 return NGX_OK;
811 } 815 }
812 816
813 r->expect_tested = 1; 817 r->expect_tested = 1;