I'm building an Portable Class Library project. Using HttpClient class ( Installed from NuGet Packages ).
Now. I want to make HttpClient using Proxy by pass an HttpClientHandler to it constructor ( HttpClientHandler have an Proxy attribute, we will assign an WebProxy instance to it ). The problem is Portable Class Library not support WebProxy class. It have only IWebProxy interace.
I searched on Google, NuGet Package, but I can't find out any solution for this case. Please tell me. How can I solve this ( or another way to make HttpClient using Proxy )
There is no implementation of IWebProxy for PCLs, but it is a very simple interface that you can easily implement on your own. Something like this for the same proxy on all destinations:
public class Proxy : System.Net.IWebProxy
{
public System.Net.ICredentials Credentials
{
get;
set;
}
private readonly Uri _proxyUri;
public Proxy(Uri proxyUri)
{
_proxyUri = proxyUri;
}
public Uri GetProxy(Uri destination)
{
return _proxyUri;
}
public bool IsBypassed(Uri host)
{
return false;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.