jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
changeset 21344 13091b742137
parent 20787 ab071ce90368
child 21428 e408bf58d482
equal deleted inserted replaced
21343:2a4c97049dc6 21344:13091b742137
   901         return false;
   901         return false;
   902     }
   902     }
   903 
   903 
   904     private String getHostAndPort(URL url) {
   904     private String getHostAndPort(URL url) {
   905         String host = url.getHost();
   905         String host = url.getHost();
       
   906         final String hostarg = host;
       
   907         try {
       
   908             // lookup hostname and use IP address if available
       
   909             host = AccessController.doPrivileged(
       
   910                 new PrivilegedExceptionAction<String>() {
       
   911                     public String run() throws IOException {
       
   912                             InetAddress addr = InetAddress.getByName(hostarg);
       
   913                             return addr.getHostAddress();
       
   914                     }
       
   915                 }
       
   916             );
       
   917         } catch (PrivilegedActionException e) {}
   906         int port = url.getPort();
   918         int port = url.getPort();
   907         if (port == -1) {
   919         if (port == -1) {
   908             String scheme = url.getProtocol();
   920             String scheme = url.getProtocol();
   909             if ("http".equals(scheme)) {
   921             if ("http".equals(scheme)) {
   910                 return host + ":80";
   922                 return host + ":80";