title: HttpURLConnection.getResponseCode() does'nt return 301 (in java)
body: <p>I'm trying to capture HTTPs with 301 status code using java.net.* libs and not using sockets directly.
  but the problem is that HttpURLConnection.getResponseCode() this method doesn’t return 301 status code, instead when it encounters headers with 301 status code it automatically places a slash after the URL and try again and obviously it would return 200 status code, without any warning or notification just like a browser. what i want is to see 301 status code back from HttpURLConnection.getResponseCode().
  here's my code:</p>
  
  <pre><code>domain.http_Con = (HttpURLConnection)url.openConnection();
  int res = domain.http_Con.getResponseCode();
  System.out.print(res);
  </code></pre>
  
  <p>i just want res 301 if it is a 301.</p>
  
  <p>p.s:
   i want to detect directories by 301.</p>