title: Check status code for a request made via proxy using java
body: <p>I am trying to make an http request with proxy using Java and get the response code in an integer variable.</p>
  
  <p>The method I am using is:</p>
  
  <pre><code>public static int getResponseCode(String urlString, Proxy p) throws MalformedURLException, IOException{
  URL url = new URL(urlString);
  HttpResponse urlresp = new DefaultHttpClient().execute(new HttpGet(urlString));
  int resp_Code = urlresp.getStatusLine().getStatusCode();
  return resp_Code;
  }
  </code></pre>
  
  <p>I am passing a proxy parameter but I am not sure how to use it while making the request. I tried to look up resources online but was unable to find an apt solution. </p>
  
  <p>I tried the below solution but was unsure how to get the response code here:</p>
  
  <pre><code>HttpHost proxy = new HttpHost("proxy.com", 80, "http");
  DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
  CloseableHttpClient httpclient = HttpClients.custom()
                  .setRoutePlanner(routePlanner)
                  .build();
  </code></pre>