title: Getting http 407 error as an IOException
body: <p>I'm using in my android application the <code>HttpURLConnection</code> through a proxy where an authentication is needed. Here is my code and I will explain you after my problem.</p>
  
  <pre><code>HttpURLConnection connection = null;
  int responseCode = -1;
  try {
      connection = (HttpURLConnection) myUrl.openConnection();
      connection.setInstanceFollowRedirects(false);
      connection.setConnectTimeout(DEFAULT_TIMEOUT);
      connection.setReadTimeout(DEFAULT_TIMEOUT);
  
      responseCode = connection.getResponseCode();
      System.out.println("ResponseCode = " + responseCode);
  } catch (IOException e) {
      System.out.println("Exception : " + e.getMessage());
  }
  </code></pre>
  
  <p>My problem is that I get an exception on the getResponseCode() method which has the following message : <code>Failed to authenticate with proxy</code>.
  Usually, this specific error has an http error code : 407. But here I just got an exception but not a response code with the 407 value.</p>
  
  <p>I have the solution to apply the login and password to connect to the proxy, but I want to apply this solution only in the case there is a 407 error (and not each time I catch an exception).</p>
  
  <p>Any idea will be appreciated.
  Thanks.</p>