src/share/classes/sun/net/www/protocol/https/HttpsClient.java

Print this page




 333         if (useCache) {
 334             /* see if one's already around */
 335             ret = (HttpsClient) kac.get(url, sf);
 336             if (ret != null && httpuc != null &&
 337                 httpuc.streaming() &&
 338                 httpuc.getRequestMethod() == "POST") {
 339                 if (!ret.available())
 340                     ret = null;
 341             }
 342 
 343             if (ret != null) {
 344                 if ((ret.proxy != null && ret.proxy.equals(p)) ||
 345                     (ret.proxy == null && p == null)) {
 346                     synchronized (ret) {
 347                         ret.cachedHttpClient = true;
 348                         assert ret.inCache;
 349                         ret.inCache = false;
 350                         if (httpuc != null && ret.needsTunneling())
 351                             httpuc.setTunnelState(TUNNELING);
 352                         PlatformLogger logger = HttpURLConnection.getHttpLogger();
 353                         if (logger.isLoggable(PlatformLogger.FINEST)) {
 354                             logger.finest("KeepAlive stream retrieved from the cache, " + ret);
 355                         }
 356                     }
 357                 } else {
 358                     // We cannot return this connection to the cache as it's
 359                     // KeepAliveTimeout will get reset. We simply close the connection.
 360                     // This should be fine as it is very rare that a connection
 361                     // to the same host will not use the same proxy.
 362                     synchronized(ret) {
 363                         ret.inCache = false;
 364                         ret.closeServer();
 365                     }
 366                     ret = null;
 367                 }
 368             }
 369         }
 370         if (ret == null) {
 371             ret = new HttpsClient(sf, url, p, connectTimeout);
 372         } else {
 373             SecurityManager security = System.getSecurityManager();




 333         if (useCache) {
 334             /* see if one's already around */
 335             ret = (HttpsClient) kac.get(url, sf);
 336             if (ret != null && httpuc != null &&
 337                 httpuc.streaming() &&
 338                 httpuc.getRequestMethod() == "POST") {
 339                 if (!ret.available())
 340                     ret = null;
 341             }
 342 
 343             if (ret != null) {
 344                 if ((ret.proxy != null && ret.proxy.equals(p)) ||
 345                     (ret.proxy == null && p == null)) {
 346                     synchronized (ret) {
 347                         ret.cachedHttpClient = true;
 348                         assert ret.inCache;
 349                         ret.inCache = false;
 350                         if (httpuc != null && ret.needsTunneling())
 351                             httpuc.setTunnelState(TUNNELING);
 352                         PlatformLogger logger = HttpURLConnection.getHttpLogger();
 353                         if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
 354                             logger.finest("KeepAlive stream retrieved from the cache, " + ret);
 355                         }
 356                     }
 357                 } else {
 358                     // We cannot return this connection to the cache as it's
 359                     // KeepAliveTimeout will get reset. We simply close the connection.
 360                     // This should be fine as it is very rare that a connection
 361                     // to the same host will not use the same proxy.
 362                     synchronized(ret) {
 363                         ret.inCache = false;
 364                         ret.closeServer();
 365                     }
 366                     ret = null;
 367                 }
 368             }
 369         }
 370         if (ret == null) {
 371             ret = new HttpsClient(sf, url, p, connectTimeout);
 372         } else {
 373             SecurityManager security = System.getSecurityManager();