This code example is very similar to the first GET example. The only difference here is the line of code that tells the HttpClient the address of the proxy server.


HttpClient httpClient = new HttpClient();
 httpClient.Proxy = new Uri("http://localhost:8888/"); // default address of fiddler
 HttpGet httpGet = new HttpGet(new Uri("http://www.codescales.com"));
 HttpResponse httpResponse = httpClient.Execute(httpGet);

 Console.WriteLine("Response Code: " + httpResponse.ResponseCode);
 Console.WriteLine("Response Content: " + EntityUtils.ToString(httpResponse.Entity));

You can use the Fiddler tool as a local proxy on your machine to test the proxy functionality. The Fiddler tool also helps a lot with debugging issues related to Http communication. See the “Http Tools” section on the right to download fiddler.