org.apache.commons.httpclient.contrib.proxy
Class PluginProxyUtil
java.lang.Object
org.apache.commons.httpclient.contrib.proxy.PluginProxyUtil
public class PluginProxyUtil
- extends java.lang.Object
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 Summary |
static org.apache.commons.httpclient.ProxyHost |
detectProxy(java.net.URL sampleURL)
Returns the Proxy Host information using settings from the java plugin. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PluginProxyUtil
public PluginProxyUtil()
detectProxy
public static org.apache.commons.httpclient.ProxyHost detectProxy(java.net.URL sampleURL)
throws ProxyDetectionException
- Returns the Proxy Host information using settings from the java plugin.
- Parameters:
sampleURL
- the url target for which proxy host information is
required
- Returns:
- the proxy host info (name and port) or null if a direct
connection is allowed to the target url.
- Throws:
ProxyDetectionException
- if detection failed