Click here to Skip to main content
15,888,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I came up with this idea in how to check if a proxy is http / https & alive or not. It's a quick fix and not at all optimal in reality, but I couldnt for the life of me find docs about testing proxies online so im asking here.

What im doing is this, im putting my code into a try catch statement and if it works then it has to be a http/https and (alive) and if it fails its either because its not http/https because the httpwebrequest does only support those two (as far as I have read) or its a http/https but couldnt connect (dead)

try
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com");
    WebProxy myproxy = new WebProxy("61.183.8.45", 94);
    myproxy.BypassProxyOnLocal = false;
    request.Proxy = myproxy;
    request.Method = "GET";
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    MessageBox.Show(response.StatusCode.ToString());
}
catch (Exception)
{
    MessageBox.Show("Could not connect because the proxy server is dead");
}


Now is there a way to "fool proof" this more? For example is there a way to check the type of the proxy? Http/https/socks5 etc

What I have tried:

I've tried looking on Google for docs and answeres but I found nothing that fits my problem.
Posted
Comments
Kornfeld Eliyahu Peter 30-Apr-17 12:56pm    
Remove the protocol...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900