comparison src/http/ngx_http_request_body.c @ 8295:5649079a41f4 quic

Parsing HTTP/3 request body.
author Roman Arutyunyan <arut@nginx.com>
date Fri, 27 Mar 2020 19:41:06 +0300
parents 2c4dbcd6f2e4
children e5d4f057a6cb
comparison
equal deleted inserted replaced
8294:32db41d603cd 8295:5649079a41f4
341 if (n == NGX_AGAIN) { 341 if (n == NGX_AGAIN) {
342 break; 342 break;
343 } 343 }
344 344
345 if (n == 0) { 345 if (n == 0) {
346 ngx_log_error(NGX_LOG_INFO, c->log, 0, 346 rb->buf->last_buf = 1;
347 "client prematurely closed connection"); 347 }
348 } 348
349 349 if (n == NGX_ERROR) {
350 if (n == 0 || n == NGX_ERROR) {
351 c->error = 1; 350 c->error = 1;
352 return NGX_HTTP_BAD_REQUEST; 351 return NGX_HTTP_BAD_REQUEST;
353 } 352 }
354 353
355 rb->buf->last += n; 354 rb->buf->last += n;
356 r->request_length += n; 355 r->request_length += n;
357 356
358 if (n == rest) { 357 if (n == rest || n == 0) {
359 /* pass buffer to request body filter chain */ 358 /* pass buffer to request body filter chain */
360 359
361 out.buf = rb->buf; 360 out.buf = rb->buf;
362 out.next = NULL; 361 out.next = NULL;
363 362
803 ngx_int_t n; 802 ngx_int_t n;
804 ngx_str_t *expect; 803 ngx_str_t *expect;
805 804
806 if (r->expect_tested 805 if (r->expect_tested
807 || r->headers_in.expect == NULL 806 || r->headers_in.expect == NULL
808 || r->http_version < NGX_HTTP_VERSION_11 807 || r->http_version != NGX_HTTP_VERSION_11)
809 #if (NGX_HTTP_V2)
810 || r->stream != NULL
811 #endif
812 )
813 { 808 {
814 return NGX_OK; 809 return NGX_OK;
815 } 810 }
816 811
817 r->expect_tested = 1; 812 r->expect_tested = 1;
912 rb->rest = 0; 907 rb->rest = 0;
913 b->last = cl->buf->pos; 908 b->last = cl->buf->pos;
914 b->last_buf = 1; 909 b->last_buf = 1;
915 } 910 }
916 911
912 if (cl->buf->last_buf && rb->rest > 0) {
913 /* XXX client prematurely closed connection */
914 return NGX_ERROR;
915 }
916
917 *ll = tl; 917 *ll = tl;
918 ll = &tl->next; 918 ll = &tl->next;
919 } 919 }
920 920
921 rc = ngx_http_top_request_body_filter(r, out); 921 rc = ngx_http_top_request_body_filter(r, out);
948 if (rb->chunked == NULL) { 948 if (rb->chunked == NULL) {
949 return NGX_HTTP_INTERNAL_SERVER_ERROR; 949 return NGX_HTTP_INTERNAL_SERVER_ERROR;
950 } 950 }
951 951
952 r->headers_in.content_length_n = 0; 952 r->headers_in.content_length_n = 0;
953 rb->rest = 3; 953
954 #if (NGX_HTTP_V3)
955 if (r->http_version == NGX_HTTP_VERSION_30) {
956 rb->rest = 1;
957
958 } else
959 #endif
960 {
961 rb->rest = 3;
962 }
954 } 963 }
955 964
956 out = NULL; 965 out = NULL;
957 ll = &out; 966 ll = &out;
958 967