I have a list of proxies that I want to go through and check to make sure they work, and also check that they do not require a username and password.
However, the test does not seem to work correctly. For example, I have one proxy server, which, as I know, requires the use of a username and password, but it somehow passes the test.
Here is an example of the code that I have:
HttpWebRequest webReq = (HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.google.com"); webReq.Proxy = new WebProxy(proxy); HttpWebResponse webRes = (HttpWebResponse)webReq.GetResponse(); if (webRes.StatusCode != HttpStatusCode.ProxyAuthenticationRequired) { Stream myStream = webRes.GetResponseStream(); if (myStream != null) { success = true; } }
For example, the following proxy requires authentication: "66.60.148.11{128". However, when I run the code, webRes.StatusCode returns as OK and passes the test webRes.StatusCode! = HttpStatusCode.ProxyAuthenticationRequired.
Any ideas or suggestions are appreciated.
Thanks!
source share