コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #5
0
ファイル: MyCurl.cs プロジェクト: qyb156/AuroraDNS.GUI
        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);
        }