大家好,又见面了,我是你们的朋友全栈君。
因为.net core 的System.Net 中没有提供WebProxy这个方法,所以可以根据需求实现一个.
public class CoreWebProxy : IWebProxy
{
public readonly Uri Uri;
private readonly bool bypass;
public CoreWebProxy(Uri uri, ICredentials credentials = null, bool bypass = false)
{
Uri = uri;
this.bypass = bypass;
Credentials = credentials;
}
public ICredentials Credentials { get; set; }
public Uri GetProxy(Uri destination) => Uri;
public bool IsBypassed(Uri host) => bypass;
public override int GetHashCode()
{
if (Uri == null)
{
return -1;
}
return Uri.GetHashCode();
}
}
参考:
转载于:https://my.oschina.net/idoop/blog/914925
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/151983.html原文链接:https://javaforall.net