Пример #1
0
        public static string f_https_getTextByUrl(string url)
        {
            var dataRecorder = new EasyDataRecorder();

            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_DEFAULT);
            try
            {
                using (Easy easy = new Easy())
                {
                    easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, (Easy.WriteFunction)dataRecorder.HandleWrite);

                    Easy.SSLContextFunction sf = new Easy.SSLContextFunction(OnSSLContext);
                    easy.SetOpt(CURLoption.CURLOPT_SSL_CTX_FUNCTION, sf);

                    easy.SetOpt(CURLoption.CURLOPT_URL, url);
                    //easy.SetOpt(CURLoption.CURLOPT_CAINFO, "ca-bundle.crt");
                    easy.SetOpt(CURLoption.CURLOPT_CAINFO, "ca-bundle.crt");


                    easy.Perform();
                }
            }
            finally
            {
                Curl.GlobalCleanup();
            }

            string s = Encoding.UTF8.GetString(dataRecorder.Written.ToArray());

            return(s);
        }
Пример #2
0
        public static string f_http_getTextByUrl(string url)
        {
            var dataRecorder = new EasyDataRecorder();

            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_DEFAULT);
            try
            {
                using (Easy easy = new Easy())
                {
                    easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, (Easy.WriteFunction)dataRecorder.HandleWrite);
                    easy.Perform();
                }
            }
            finally
            {
                Curl.GlobalCleanup();
            }

            string s = Encoding.UTF8.GetString(dataRecorder.Written.ToArray());

            return(s);
        }