equal
deleted
inserted
replaced
310 protected volatile String authenticatorKey; |
310 protected volatile String authenticatorKey; |
311 |
311 |
312 private CookieHandler cookieHandler; |
312 private CookieHandler cookieHandler; |
313 private final ResponseCache cacheHandler; |
313 private final ResponseCache cacheHandler; |
314 |
314 |
|
315 private volatile boolean usingProxy; |
|
316 |
315 // the cached response, and cached response headers and body |
317 // the cached response, and cached response headers and body |
316 protected CacheResponse cachedResponse; |
318 protected CacheResponse cachedResponse; |
317 private MessageHeader cachedHeaders; |
319 private MessageHeader cachedHeaders; |
318 private InputStream cachedInputStream; |
320 private InputStream cachedInputStream; |
319 |
321 |
320 /* output stream to server */ |
322 /* output stream to server */ |
321 protected PrintStream ps = null; |
323 protected PrintStream ps = null; |
322 |
|
323 |
324 |
324 /* buffered error stream */ |
325 /* buffered error stream */ |
325 private InputStream errorStream = null; |
326 private InputStream errorStream = null; |
326 |
327 |
327 /* User set Cookies */ |
328 /* User set Cookies */ |
1238 http = getNewHttpClient(url, instProxy, connectTimeout, false); |
1239 http = getNewHttpClient(url, instProxy, connectTimeout, false); |
1239 http.setReadTimeout(readTimeout); |
1240 http.setReadTimeout(readTimeout); |
1240 } |
1241 } |
1241 } |
1242 } |
1242 |
1243 |
|
1244 usingProxy = usingProxy || usingProxyInternal(); |
1243 ps = (PrintStream)http.getOutputStream(); |
1245 ps = (PrintStream)http.getOutputStream(); |
1244 } catch (IOException e) { |
1246 } catch (IOException e) { |
1245 throw e; |
1247 throw e; |
1246 } |
1248 } |
1247 // constructor to HTTP client calls openserver |
1249 // constructor to HTTP client calls openserver |
2915 * Disconnect from the web server at the first 401 error. Do not |
2917 * Disconnect from the web server at the first 401 error. Do not |
2916 * disconnect when using a proxy, a good proxy should have already |
2918 * disconnect when using a proxy, a good proxy should have already |
2917 * closed the connection to the web server. |
2919 * closed the connection to the web server. |
2918 */ |
2920 */ |
2919 private void disconnectWeb() throws IOException { |
2921 private void disconnectWeb() throws IOException { |
2920 if (usingProxy() && http.isKeepingAlive()) { |
2922 if (usingProxyInternal() && http.isKeepingAlive()) { |
2921 responseCode = -1; |
2923 responseCode = -1; |
2922 // clean up, particularly, skip the content part |
2924 // clean up, particularly, skip the content part |
2923 // of a 401 error response |
2925 // of a 401 error response |
2924 reset(); |
2926 reset(); |
2925 } else { |
2927 } else { |
3018 if (cachedHeaders != null) { |
3020 if (cachedHeaders != null) { |
3019 cachedHeaders.reset(); |
3021 cachedHeaders.reset(); |
3020 } |
3022 } |
3021 } |
3023 } |
3022 |
3024 |
3023 public boolean usingProxy() { |
3025 /** |
|
3026 * Returns true only if the established connection is using a proxy |
|
3027 */ |
|
3028 boolean usingProxyInternal() { |
3024 if (http != null) { |
3029 if (http != null) { |
3025 return (http.getProxyHostUsed() != null); |
3030 return (http.getProxyHostUsed() != null); |
3026 } |
3031 } |
|
3032 return false; |
|
3033 } |
|
3034 |
|
3035 /** |
|
3036 * Returns true if the established connection is using a proxy |
|
3037 * or if a proxy is specified for the inactive connection |
|
3038 */ |
|
3039 @Override |
|
3040 public boolean usingProxy() { |
|
3041 if (usingProxy || usingProxyInternal()) |
|
3042 return true; |
|
3043 |
|
3044 if (instProxy != null) |
|
3045 return instProxy.type().equals(Proxy.Type.HTTP); |
|
3046 |
3027 return false; |
3047 return false; |
3028 } |
3048 } |
3029 |
3049 |
3030 // constant strings represent set-cookie header names |
3050 // constant strings represent set-cookie header names |
3031 private static final String SET_COOKIE = "set-cookie"; |
3051 private static final String SET_COOKIE = "set-cookie"; |