< prev index next >

src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java

Print this page

        

*** 310,328 **** protected volatile String authenticatorKey; private CookieHandler cookieHandler; private final ResponseCache cacheHandler; // the cached response, and cached response headers and body protected CacheResponse cachedResponse; private MessageHeader cachedHeaders; private InputStream cachedInputStream; /* output stream to server */ protected PrintStream ps = null; - /* buffered error stream */ private InputStream errorStream = null; /* User set Cookies */ private boolean setUserCookies = true; --- 310,329 ---- protected volatile String authenticatorKey; private CookieHandler cookieHandler; private final ResponseCache cacheHandler; + private volatile boolean usingProxy; + // the cached response, and cached response headers and body protected CacheResponse cachedResponse; private MessageHeader cachedHeaders; private InputStream cachedInputStream; /* output stream to server */ protected PrintStream ps = null; /* buffered error stream */ private InputStream errorStream = null; /* User set Cookies */ private boolean setUserCookies = true;
*** 1238,1247 **** --- 1239,1249 ---- http = getNewHttpClient(url, instProxy, connectTimeout, false); http.setReadTimeout(readTimeout); } } + usingProxy = usingProxy || usingProxyInternal(); ps = (PrintStream)http.getOutputStream(); } catch (IOException e) { throw e; } // constructor to HTTP client calls openserver
*** 2915,2925 **** * Disconnect from the web server at the first 401 error. Do not * disconnect when using a proxy, a good proxy should have already * closed the connection to the web server. */ private void disconnectWeb() throws IOException { ! if (usingProxy() && http.isKeepingAlive()) { responseCode = -1; // clean up, particularly, skip the content part // of a 401 error response reset(); } else { --- 2917,2927 ---- * Disconnect from the web server at the first 401 error. Do not * disconnect when using a proxy, a good proxy should have already * closed the connection to the web server. */ private void disconnectWeb() throws IOException { ! if (usingProxyInternal() && http.isKeepingAlive()) { responseCode = -1; // clean up, particularly, skip the content part // of a 401 error response reset(); } else {
*** 3018,3034 **** if (cachedHeaders != null) { cachedHeaders.reset(); } } ! public boolean usingProxy() { if (http != null) { return (http.getProxyHostUsed() != null); } return false; } // constant strings represent set-cookie header names private static final String SET_COOKIE = "set-cookie"; private static final String SET_COOKIE2 = "set-cookie2"; /** --- 3020,3054 ---- if (cachedHeaders != null) { cachedHeaders.reset(); } } ! /** ! * Returns true only if the established connection is using a proxy ! */ ! boolean usingProxyInternal() { if (http != null) { return (http.getProxyHostUsed() != null); } return false; } + /** + * Returns true if the established connection is using a proxy + * or if a proxy is specified for the inactive connection + */ + @Override + public boolean usingProxy() { + if (usingProxy || usingProxyInternal()) + return true; + + if (instProxy != null) + return instProxy.type().equals(Proxy.Type.HTTP); + + return false; + } + // constant strings represent set-cookie header names private static final String SET_COOKIE = "set-cookie"; private static final String SET_COOKIE2 = "set-cookie2"; /**
< prev index next >