/// <summary> /// 从HttpContent转换得到 /// </summary> /// <param name="httpContent">httpContent实例</param> /// <param name="disposeHttpContent">是否释放httpContent</param> /// <returns></returns> public static async Task <FormContent> ParseAsync(HttpContent httpContent, bool disposeHttpContent = true) { if (httpContent == null) { return(new FormContent()); } if (httpContent is FormContent formContent) { return(formContent); } formContent = new FormContent(); var byteArray = await httpContent.ReadAsByteArrayAsync().ConfigureAwait(false); formContent.AddForm(byteArray); if (disposeHttpContent == true) { httpContent.Dispose(); } return(formContent); }