aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request_body.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/ngx_http_request_body.c')
-rw-r--r--src/http/ngx_http_request_body.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index 71d7e9ab8..204253ca2 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -329,11 +329,10 @@ ngx_http_do_read_client_request_body(ngx_http_request_t *r)
}
if (n == 0) {
- ngx_log_error(NGX_LOG_INFO, c->log, 0,
- "client prematurely closed connection");
+ rb->buf->last_buf = 1;
}
- if (n == 0 || n == NGX_ERROR) {
+ if (n == NGX_ERROR) {
c->error = 1;
return NGX_HTTP_BAD_REQUEST;
}
@@ -799,7 +798,16 @@ ngx_http_discard_request_body_filter(ngx_http_request_t *r, ngx_buf_t *b)
for ( ;; ) {
- rc = ngx_http_parse_chunked(r, b, rb->chunked);
+ switch (r->http_version) {
+#if (NGX_HTTP_V3)
+ case NGX_HTTP_VERSION_30:
+ rc = ngx_http_v3_parse_request_body(r, b, rb->chunked);
+ break;
+#endif
+
+ default: /* HTTP/1.x */
+ rc = ngx_http_parse_chunked(r, b, rb->chunked);
+ }
if (rc == NGX_OK) {
@@ -871,11 +879,7 @@ ngx_http_test_expect(ngx_http_request_t *r)
if (r->expect_tested
|| r->headers_in.expect == NULL
- || r->http_version < NGX_HTTP_VERSION_11
-#if (NGX_HTTP_V2)
- || r->stream != NULL
-#endif
- )
+ || r->http_version != NGX_HTTP_VERSION_11)
{
return NGX_OK;
}
@@ -980,6 +984,11 @@ ngx_http_request_body_length_filter(ngx_http_request_t *r, ngx_chain_t *in)
b->last_buf = 1;
}
+ if (cl->buf->last_buf && rb->rest > 0) {
+ /* XXX client prematurely closed connection */
+ return NGX_ERROR;
+ }
+
*ll = tl;
ll = &tl->next;
}
@@ -1020,6 +1029,12 @@ ngx_http_request_body_chunked_filter(ngx_http_request_t *r, ngx_chain_t *in)
r->headers_in.content_length_n = 0;
rb->rest = cscf->large_client_header_buffers.size;
+
+#if (NGX_HTTP_V3)
+ if (r->http_version == NGX_HTTP_VERSION_30) {
+ rb->rest = 1;
+ }
+#endif
}
out = NULL;
@@ -1040,7 +1055,16 @@ ngx_http_request_body_chunked_filter(ngx_http_request_t *r, ngx_chain_t *in)
cl->buf->file_pos,
cl->buf->file_last - cl->buf->file_pos);
- rc = ngx_http_parse_chunked(r, cl->buf, rb->chunked);
+ switch (r->http_version) {
+#if (NGX_HTTP_V3)
+ case NGX_HTTP_VERSION_30:
+ rc = ngx_http_v3_parse_request_body(r, cl->buf, rb->chunked);
+ break;
+#endif
+
+ default: /* HTTP/1.x */
+ rc = ngx_http_parse_chunked(r, cl->buf, rb->chunked);
+ }
if (rc == NGX_OK) {