【发布时间】:2018-06-13 16:59:02
【问题描述】:
我想知道使用 Post 或 PostAsync 时实际传输了多少字节。我正在使用类似于以下的代码。我可以查看 filePath 的字节,但在我的真实代码中,我在读取和发送之间对文件流进行了一些操作。如果你拔掉MyFilteredContent这一行,你会怎么做?
async Task<bool> SendFile(string filePath)
{
using (HttpContent fileContent = new FileContent(filePath))
using (MyFilteredContent filteredContent = new MyFilteredContent(fileContent))
{
var t = await MyAppSettings.TargetUrl
.AllowAnyHttpStatus()
.PostAsync(filteredContent);
if (t.IsSuccessStatusCode)
{
return true;
}
throw new Exception("blah blah");
}
}
【问题讨论】:
-
正在使用 DelegatingHandler,重写 SendAsync 以获取正在发送的请求的字节,然后配置 FlurlHttp 设置以使用处理程序选项..?
-
听起来不错。怎么做?