message: Fix chunked multipart parser
diff: @@ -868,9 +868,12 @@ static int http_request_on_body(swoole_http_parser *parser, const char *at, size
  {
  http_context *ctx = (http_context *) parser->data;
  - if (ctx->recv_chunked)
  + if (length == 0)
  {
  - if (length != 0)
  + return 0;
  + }
  +
  + if (ctx->recv_chunked)
  {
  if (ctx->request.chunked_body == nullptr)
  {
  @@ -882,14 +885,12 @@ static int http_request_on_body(swoole_http_parser *parser, const char *at, size
  }
  swString_append_ptr(ctx->request.chunked_body, at, length);
  }
  - return 0;
  - }
  -
  + else
  + {
  ctx->request.body_length += length;
  + }
  - swTraceLog(SW_TRACE_HTTP, "request body_length=%ld", length);
  -
  - if (ctx->parse_body && ctx->request.post_form_urlencoded)
  + if (!ctx->recv_chunked && ctx->parse_body && ctx->request.post_form_urlencoded)
  {
  sapi_module.treat_data(
  PARSE_STRING,
  @@ -919,6 +920,17 @@ static int http_request_on_body(swoole_http_parser *parser, const char *at, size
  static int http_request_message_complete(swoole_http_parser *parser)
  {
  http_context *ctx = (http_context *) parser->data;
  + size_t content_length = ctx->request.chunked_body ? ctx->request.chunked_body->length : ctx->request.body_length;
  +
  + if (ctx->request.chunked_body != nullptr && ctx->parse_body && ctx->request.post_form_urlencoded)
  + {
  + /* parse dechunked content */
  + sapi_module.treat_data(
  + PARSE_STRING,
  + estrndup(ctx->request.chunked_body->str, content_length), // do not free, it will be freed by treat_data
  + swoole_http_init_and_read_property(swoole_http_request_ce, ctx->request.zobject, &ctx->request.zpost, ZEND_STRL("post"))
  + );
  + }
  if (ctx->mt_parser)
  {
  multipart_parser_free(ctx->mt_parser);
  @@ -926,6 +938,8 @@ static int http_request_message_complete(swoole_http_parser *parser)
  }
  ctx->completed = 1;
  + swTraceLog(SW_TRACE_HTTP, "request body length=%ld", content_length);
  +
  return 1; /* return from execute */
  }
  