HttpClient的HttpWebRequest的VS [英] HttpClient vs HttpWebRequest
问题描述
我有一个大的文件,我已经发送给Web API客户端...的数据是多部分。
问题是,如果文件是通过HTTP Web请求发送,然后将其快速上传上的WebAPI。对于这个要求,文件内容写入了直接请求流。
I have a large file which I have to send to a web api client...The data is multi part. The issue is , if the file is sent over http web request, then it is uploaded quickly on the webapi. For this request, file contents are written over the request stream directly.
在哪里,如果将同一文件发送过来的HttpClient(.NET 4.5)相比,HTTP网页请求时上传速度很慢。我正在使用的HttpClient后异步multipartformdatacontent。
Where as if the same file is sent over Httpclient (.net 4.5), the upload is slow when compared to http web request. I am using multipartformdatacontent in Httpclient post async.
所以,对于大文件,我们必须只使用Web请求?或者是有,使上传速度更快的HttpClient上的任何设置?
So, for large files, do we have to use only web request? or is there any settings on Httpclient that makes the upload faster?
推荐答案
的HttpClient
更像是一个头少的浏览器。它一个强大的和理想的工具,如果你将要创建多个HTTP请求。例如,您可以设置默认头之类的东西。以下是前5种方法从不同的的HttpWebRequest
这是从的here
HttpClient
is more like a head-less browser. It a powerfull and ideal tool if you are going to be creating many http request. For example you can set default headers and stuff. Here are the top 5 ways it differs from an HttpWebRequest
which is taken from here
- 一个HttpClient的实例是配置扩展,设置默认标题,取消未完成的请求等等。 的地方
- 当你通过一个HttpClient的实例喜欢,你可以发出尽可能多的请求。
- HttpClients不依赖于特定的HTTP服务器或主机;你可以使用相同的HttpClient的实例提交的HTTP请求。
- 您可以从HttpClient的派生来创建特定的网站或图案专门的客户端
- 的HttpClient采用了全新的面向任务的模式来处理异步请求使得它极大地更易于管理和协调多个未完成的请求。
这篇关于HttpClient的HttpWebRequest的VS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!