org.apache.commons.httpclient.contrib.proxy
public class: PluginProxyUtil [javadoc |
source]
java.lang.Object
org.apache.commons.httpclient.contrib.proxy.PluginProxyUtil
A utility class that gives applets the ability to detect proxy host settings.
This was adapted from a post from Chris Forster on 20030227 to a Sun Java
forum here:
http://forum.java.sun.com/thread.jspa?threadID=364342&tstart=120
The algorithm - which relies on Sun java plugin internal classes in some
cases - was maintained, but the following changes were made:
1. Logging was used to allow control of debug type messages.
2. Reflection is used instead of direct references to Sun internal classes
to avoid the need to have these classes in the CLASSPATH to compile.
3. Removed the use of global variables to allow this class to be used in
a multi-threaded environment.
4. Add the use of exception to indicate to the caller when proxy detection
failed as opposed to when no proxy is configured.
DISCLAIMER: HttpClient developers DO NOT actively support this component.
The component is provided as a reference material, which may be inappropriate
for use without additional customization.
| Method from org.apache.commons.httpclient.contrib.proxy.PluginProxyUtil Summary: |
|---|
|
detectProxy |
| Method from org.apache.commons.httpclient.contrib.proxy.PluginProxyUtil Detail: |
public static ProxyHost detectProxy(URL sampleURL) throws ProxyDetectionException {
ProxyHost result = null;
String javaVers = System.getProperty("java.runtime.version");
if (LOG.isDebugEnabled()) {
LOG.debug("About to attempt auto proxy detection under Java " +
"version:"+javaVers);
}
// If specific, known detection methods fail may try fallback
// detection method
boolean invokeFailover = false;
if (javaVers.startsWith("1.3")) {
result = detectProxySettingsJDK13(sampleURL);
if (result == null) {
invokeFailover = true;
}
} else if (javaVers.startsWith("1.4") || (javaVers.startsWith("1.5") || javaVers.startsWith("1.6"))) {
result = detectProxySettingsJDK14_JDK15_JDK16(sampleURL);
if (result == null) {
invokeFailover = true;
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Sun Plugin reported java version not 1.3.X, " +
"1.4.X, 1.5.X or 1.6.X - trying failover detection...");
}
invokeFailover = true;
}
if (invokeFailover) {
if (LOG.isDebugEnabled()) {
LOG.debug("Using failover proxy detection...");
}
result = getPluginProxyConfigSettings();
}
if (NO_PROXY_HOST.equals(result)) {
result = null;
}
return result;
}
Returns the Proxy Host information using settings from the java plugin. |