c# HTTP多部分MIME解析器
本文关键字:MIME HTTP 多部 | 更新日期: 2023-09-27 18:17:39
我从HTTP调用中获得多部分MIME响应,需要提取部分。我在寻找一种简单的方法。
我使用System.Net.Http方法来获取内容,但是提取响应部分让我感到困惑。
HttpClient zClient = new HttpClient();
Uri zAddress = new Uri("http://someDomain.com");
HttpContent content = new StringContent(sb.ToString());
HttpResponseMessage response = zClient.PostAsync(zAddress, content).Result;
if (response.IsSuccessStatusCode)
{
// This returns true
bool zIsMime = response.Content.IsMimeMultipartContent();
// How do I get the message parts here. This ReadAsMultipartAsync method is confusing me.
ReadAsMultipartAsync(HttpContent) ????
}
else
{
Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}
MultipartMemoryStreamProvider zMIME = await response.Content.ReadAsMultipartAsync();
是我一直在寻找的简单步骤。