Proxy Bypass – Sample code
Tuesday, April 28th, 2009Autor: nuno.lourenco
Here is a sample code for bypassing web proxies.
Useful, maybe?!
For testing your apps, or for running your unit tests, I think it’s really useful.
1: public class NoProxy : IWebProxy
2: {
3: #region Instance
4: public static readonly NoProxy Instance = new NoProxy();
5:
6: private NoProxy() { }
7: #endregion
8:
9: #region IWebProxy Members
10: public ICredentials Credentials
11: {
12: get
13: {
14: throw new NotImplementedException();
15: }
16: set
17: {
18: throw new NotImplementedException();
19: }
20: }
21:
22: public Uri GetProxy(Uri destination)
23: {
24: throw new NotImplementedException();
25: }
26:
27: public bool IsBypassed(Uri host)
28: {
29: return true;
30: }
31: #endregion
32: }
Note: All we want to do is inform that we want that the URI is to be bypassed and therefore not be under the definitions/restrictions of the proxy.
Cheers.