Ejemplo n.º 1
0
        public static string GetStringByHttp2Client(string url, bool proxyEnable = false, IWebProxy wProxy = null,
                                                    bool allowRedirect           = true)
        {
            var mHttp2Handel = new Http2Handler();

            mHttp2Handel.AutomaticRedirection = allowRedirect;
            mHttp2Handel.Proxy = proxyEnable ? wProxy : new WebProxy();
            HttpClient mHttpClient = new HttpClient(mHttp2Handel);

            mHttpClient.DefaultRequestHeaders.UserAgent.ParseAdd("AuroraDNSC/0.1");
            return(mHttpClient.GetStringAsync(url).Result);
        }
Ejemplo n.º 2
0
        public static string GetStringByHttp2Client(string url, bool proxyEnable = false, IWebProxy wProxy = null)
        {
            var mHttp2Handel = new Http2Handler();

            if (proxyEnable)
            {
                mHttp2Handel.Proxy = wProxy;
            }
            HttpClient mHttpClient = new HttpClient(mHttp2Handel);

            mHttpClient.DefaultRequestHeaders.UserAgent.ParseAdd("AuroraDNSC/0.1");
            return(mHttpClient.GetStringAsync(url).Result);
        }
Ejemplo n.º 3
0
        public static byte[] GetDataByHttp2Client(string url, bool proxyEnable = false, IWebProxy wProxy = null,
                                                  bool allowRedirect           = true)
        {
            var mHttp2Handel = new Http2Handler {
                WindowsProxyUsePolicy = WindowsProxyUsePolicy.UseWinHttpProxy
            };

            mHttp2Handel.AutomaticRedirection = allowRedirect;
            mHttp2Handel.Proxy = proxyEnable ? wProxy : new WebProxy();
            HttpClient mHttpClient = new HttpClient(mHttp2Handel);

            mHttpClient.DefaultRequestHeaders.UserAgent.ParseAdd("AuroraDNSC/0.1");
            return(mHttpClient.GetByteArrayAsync(url).Result);
        }
Ejemplo n.º 4
0
        public static byte[] GetDataByHttp2Client(string url, bool proxyEnable = false, IWebProxy wProxy = null)
        {
            var mHttp2Handel = new Http2Handler {
                WindowsProxyUsePolicy = WindowsProxyUsePolicy.UseCustomProxy
            };

            if (proxyEnable)
            {
                mHttp2Handel.Proxy = wProxy;
            }
            HttpClient mHttpClient = new HttpClient(mHttp2Handel);

            mHttpClient.DefaultRequestHeaders.UserAgent.ParseAdd("AuroraDNSC/0.1");
            return(mHttpClient.GetByteArrayAsync(url).Result);
        }
Ejemplo n.º 5
0
        public static string GetStringByHttp2Client(string url, bool proxyEnable = false, IWebProxy wProxy = null,
                                                    bool allowRedirect           = true)
        {
            var mHttp2Handel = new Http2Handler
            {
                WindowsProxyUsePolicy =
                    !proxyEnable ? WindowsProxyUsePolicy.DoNotUseProxy : WindowsProxyUsePolicy.UseCustomProxy,
                AutomaticRedirection = allowRedirect,
                Proxy = !proxyEnable ? null : wProxy
            };
            HttpClient mHttpClient = new HttpClient(mHttp2Handel);

            mHttpClient.DefaultRequestHeaders.UserAgent.ParseAdd("AuroraDNSC/0.1");
            return(mHttpClient.GetStringAsync(url).Result);
        }