Can someone provide a c# sample for https?

Posted almost 4 years ago by gac

Post a topic
Un Answered
g
gac

I tried following but it fails with 407. 


   var myProxy = new WebProxy("http://proxy.crawlera.com:8010", true);

            myProxy.Credentials = new NetworkCredential("xxx", "");

 

            var request = (HttpWebRequest)WebRequest.Create("https://httpbin.scrapinghub.com/headers");

            request.Proxy = myProxy;

            request.PreAuthenticate = true;

            request.AllowAutoRedirect = false;

            request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

 

            var response = request.GetResponse();

            Console.WriteLine("Response Status: " + ((HttpWebResponse)response).StatusDescription);

            Console.WriteLine("\nResponse Headers:\n" + ((HttpWebResponse)response).Headers);

            var dataStream = response.GetResponseStream();

            var reader = new StreamReader(dataStream);

            string responseFromServer = reader.ReadToEnd();

            Console.WriteLine("Response Body:\n" + responseFromServer);

            reader.Close();

            response.Close();


0 Votes


0 Comments

Login to post a comment