Check proxy server to check if it requires authentication

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!

+4
source share
1 answer

I would suggest that a request to a proxy server that allows it (so to speak) not to follow HTTP standards without returning a 407 status code. You can view this by doing batch sniffing with something like WireShark http: // www .wireshark.org / or using browser debugging tools such as Chromes developer tools (Ctrl + Shift + I). You can also check which status code is returned by looking at the value of webRes.StatusCode for this case.

+1
source

Source: https://habr.com/ru/post/1393200/


All Articles