jdk/src/share/classes/sun/net/www/http/HttpClient.java
changeset 9775 1b128726e887
parent 9550 c3a275ce56d3
child 10136 af9631156b25
equal deleted inserted replaced
9774:50a2b28ca54c 9775:1b128726e887
   299         if (ret == null) {
   299         if (ret == null) {
   300             ret = new HttpClient(url, p, to);
   300             ret = new HttpClient(url, p, to);
   301         } else {
   301         } else {
   302             SecurityManager security = System.getSecurityManager();
   302             SecurityManager security = System.getSecurityManager();
   303             if (security != null) {
   303             if (security != null) {
   304                 security.checkConnect(url.getHost(), url.getPort());
   304                 if (ret.proxy == Proxy.NO_PROXY || ret.proxy == null) {
       
   305                     security.checkConnect(InetAddress.getByName(url.getHost()).getHostAddress(), url.getPort());
       
   306                 } else {
       
   307                     security.checkConnect(url.getHost(), url.getPort());
       
   308                 }
   305             }
   309             }
   306             ret.url = url;
   310             ret.url = url;
   307         }
   311         }
   308         return ret;
   312         return ret;
   309     }
   313     }
   455     /*
   459     /*
   456      */
   460      */
   457     protected synchronized void openServer() throws IOException {
   461     protected synchronized void openServer() throws IOException {
   458 
   462 
   459         SecurityManager security = System.getSecurityManager();
   463         SecurityManager security = System.getSecurityManager();
       
   464 
   460         if (security != null) {
   465         if (security != null) {
   461             security.checkConnect(host, port);
   466             security.checkConnect(host, port);
   462         }
   467         }
   463 
   468 
   464         if (keepingAlive) { // already opened
   469         if (keepingAlive) { // already opened
   467 
   472 
   468         if (url.getProtocol().equals("http") ||
   473         if (url.getProtocol().equals("http") ||
   469             url.getProtocol().equals("https") ) {
   474             url.getProtocol().equals("https") ) {
   470 
   475 
   471             if ((proxy != null) && (proxy.type() == Proxy.Type.HTTP)) {
   476             if ((proxy != null) && (proxy.type() == Proxy.Type.HTTP)) {
       
   477                 sun.net.www.URLConnection.setProxiedHost(host);
   472                 privilegedOpenServer((InetSocketAddress) proxy.address());
   478                 privilegedOpenServer((InetSocketAddress) proxy.address());
   473                 usingProxy = true;
   479                 usingProxy = true;
   474                 return;
   480                 return;
   475             } else {
   481             } else {
   476                 // make direct connection
   482                 // make direct connection
   482         } else {
   488         } else {
   483             /* we're opening some other kind of url, most likely an
   489             /* we're opening some other kind of url, most likely an
   484              * ftp url.
   490              * ftp url.
   485              */
   491              */
   486             if ((proxy != null) && (proxy.type() == Proxy.Type.HTTP)) {
   492             if ((proxy != null) && (proxy.type() == Proxy.Type.HTTP)) {
       
   493                 sun.net.www.URLConnection.setProxiedHost(host);
   487                 privilegedOpenServer((InetSocketAddress) proxy.address());
   494                 privilegedOpenServer((InetSocketAddress) proxy.address());
   488                 usingProxy = true;
   495                 usingProxy = true;
   489                 return;
   496                 return;
   490             } else {
   497             } else {
   491                 // make direct connection
   498                 // make direct connection