break;
}
+ size = cl->buf->last - cl->buf->pos;
+
+ if (cl->buf->last_buf && (off_t) size < rb->rest) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client prematurely closed connection");
+ r->connection->error = 1;
+ return NGX_HTTP_BAD_REQUEST;
+ }
+
tl = ngx_chain_get_free_buf(r->pool, &rb->free);
if (tl == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
b->end = cl->buf->end;
b->flush = r->request_body_no_buffering;
- size = cl->buf->last - cl->buf->pos;
-
if ((off_t) size < rb->rest) {
cl->buf->pos = cl->buf->last;
rb->rest -= size;
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;
}
continue;
}
+ if (rc == NGX_AGAIN && cl->buf->last_buf) {
+
+ /* last body buffer */
+
+ if (rb->chunked->length > 0) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client prematurely closed connection");
+ r->connection->error = 1;
+ return NGX_HTTP_BAD_REQUEST;
+ }
+
+ rc = NGX_DONE;
+ }
+
if (rc == NGX_DONE) {
/* a whole response has been parsed successfully */
ngx_int_t rc;
ngx_connection_t *c;
ngx_http_v3_parse_data_t *st;
+ enum {
+ sw_start = 0,
+ sw_skip
+ };
c = r->connection;
st = ctx->h3_parse;
ctx->h3_parse = st;
}
- if (ctx->size) {
- ctx->length = ctx->size + 1;
- return (b->pos == b->last) ? NGX_AGAIN : NGX_OK;
- }
+ while (b->pos < b->last && ctx->size == 0) {
- while (b->pos < b->last) {
rc = ngx_http_v3_parse_data(c, st, *b->pos++);
if (rc > 0) {
}
if (rc == NGX_AGAIN) {
+ ctx->state = sw_skip;
continue;
}
/* rc == NGX_DONE */
ctx->size = st->length;
- return NGX_OK;
+ ctx->state = sw_start;
}
- if (!b->last_buf) {
+ if (ctx->state == sw_skip) {
ctx->length = 1;
return NGX_AGAIN;
}
- if (st->state) {
- goto failed;
+ if (b->pos == b->last) {
+ ctx->length = ctx->size;
+ return NGX_AGAIN;
}
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse header done");
-
- return NGX_DONE;
+ return NGX_OK;
failed: