Home » commons-httpclient-3.1-src » org.apache.commons » httpclient » protocol » [javadoc | source]
org.apache.commons.httpclient.protocol
public class: Protocol [javadoc | source]
java.lang.Object
   org.apache.commons.httpclient.protocol.Protocol
A class to encapsulate the specifics of a protocol. This class class also provides the ability to customize the set and characteristics of the protocols used.

One use case for modifying the default set of protocols would be to set a custom SSL socket factory. This would look something like the following:

Protocol myHTTPS = new Protocol( "https", new MySSLSocketFactory(), 443 );

Protocol.registerProtocol( "https", myHTTPS );
Constructor:
 public Protocol(String scheme,
    ProtocolSocketFactory factory,
    int defaultPort) 
    Constructs a new Protocol. Whether the created protocol is secure depends on the class of factory.
    Parameters:
    scheme - the scheme (e.g. http, https)
    factory - the factory for creating sockets for communication using this protocol
    defaultPort - the port this protocol defaults to
 public Protocol(String scheme,
    SecureProtocolSocketFactory factory,
    int defaultPort) 
    Constructs a new Protocol. Whether the created protocol is secure depends on the class of factory.
    Parameters:
    scheme - the scheme (e.g. http, https)
    factory - the factory for creating sockets for communication using this protocol
    defaultPort - the port this protocol defaults to
Method from org.apache.commons.httpclient.protocol.Protocol Summary:
equals,   getDefaultPort,   getProtocol,   getScheme,   getSocketFactory,   hashCode,   isSecure,   registerProtocol,   resolvePort,   toString,   unregisterProtocol
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.httpclient.protocol.Protocol Detail:
 public boolean equals(Object obj) 
    Return true if the specified object equals this object.
 public int getDefaultPort() 
    Returns the defaultPort.
 public static Protocol getProtocol(String id) throws IllegalStateException 
    Gets the protocol with the given ID.
 public String getScheme() 
    Returns the scheme.
 public ProtocolSocketFactory getSocketFactory() 
    Returns the socketFactory. If secure the factory is a SecureProtocolSocketFactory.
 public int hashCode() 
    Return a hash code for this object
 public boolean isSecure() 
    Returns true if this protocol is secure
 public static  void registerProtocol(String id,
    Protocol protocol) 
    Registers a new protocol with the given identifier. If a protocol with the given ID already exists it will be overridden. This ID is the same one used to retrieve the protocol from getProtocol(String).
 public int resolvePort(int port) 
    Resolves the correct port for this protocol. Returns the given port if valid or the default port otherwise.
 public String toString() 
    Return a string representation of this object.
 public static  void unregisterProtocol(String id) 
    Unregisters the protocol with the given ID.