You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/09/23 21:51:49 UTC

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params DefaultHttpParams.java HttpClientParams.java HttpMethodParams.java HttpParams.java

olegk       2003/09/23 12:51:49

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpClient.java
               httpclient/src/java/org/apache/commons/httpclient/params
                        DefaultHttpParams.java HttpClientParams.java
                        HttpMethodParams.java HttpParams.java
  Log:
  PR #15435 (New Preferences Architecture)
  
  - Ability to clone DefaultHttpParams and its sub-classes
  - HttpClient constructors that accept custom parameter set
  - Complete javadoc
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke & Roland Weber
  
  Revision  Changes    Path
  1.84      +64 -19    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
  
  Index: HttpClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- HttpClient.java	17 Sep 2003 23:29:05 -0000	1.83
  +++ HttpClient.java	23 Sep 2003 19:51:48 -0000	1.84
  @@ -121,40 +121,82 @@
       // ----------------------------------------------------------- Constructors
   
       /**
  -     * Creates an instance of HttpClient using the default connection manager.
  +     * Creates an instance of HttpClient using default {@link HttpClientParams parameter set}.
        * 
  -     * @see HttpClientParams#getConnectionManagerClass()
  +     * @see HttpClientParams
        */
       public HttpClient() {
  +        this(new HttpClientParams());
  +    }
   
  +    /**
  +     * Creates an instance of HttpClient using the given 
  +     * {@link HttpClientParams parameter set}.
  +     * 
  +     * @param params The {@link HttpClientParams parameters} to use.
  +     * 
  +     * @see HttpClientParams
  +     * 
  +     * @since 2.1
  +     */
  +    public HttpClient(HttpClientParams params) {
           super();
  -        try {
  -            this.httpConnectionManager = 
  -                (HttpConnectionManager) params.getConnectionManagerClass().newInstance();
  -        } catch (Exception e) {
  -            LOG.warn("Error instantiating connection manager class, defaulting to"
  -                + " SimpleHttpConnectionManager", 
  -                e);
  +        if (params == null) {
  +            throw new IllegalArgumentException("Params may not be null");  
  +        }
  +        this.params = params;
  +        this.httpConnectionManager = null;
  +        Class clazz = params.getConnectionManagerClass();
  +        if (clazz != null) {
  +            try {
  +                this.httpConnectionManager = (HttpConnectionManager) clazz.newInstance();
  +            } catch (Exception e) {
  +                LOG.warn("Error instantiating connection manager class, defaulting to"
  +                    + " SimpleHttpConnectionManager", 
  +                    e);
  +            }
  +        }
  +        if (this.httpConnectionManager == null) {
               this.httpConnectionManager = new SimpleHttpConnectionManager();
           }
       }
   
       /**
  -     * Creates an instance of HttpClient with a user specified connection manager.
  +     * Creates an instance of HttpClient with a user specified 
  +     * {@link HttpClientParams parameter set} and 
  +     * {@link HttpConnectionManager HTTP connection manager}.
  +     * 
  +     * @param params The {@link HttpClientParams parameters} to use.
        * @param httpConnectionManager The {@link HttpConnectionManager connection manager}
        * to use.
        * 
  -     * @since 2.0
  +     * @since 2.1
        */
  -    public HttpClient(HttpConnectionManager httpConnectionManager) {
  -
  +    public HttpClient(HttpClientParams params, HttpConnectionManager httpConnectionManager) {
  +        super();
           if (httpConnectionManager == null) {
               throw new IllegalArgumentException("httpConnectionManager cannot be null");  
           }
  -
  +        if (params == null) {
  +            throw new IllegalArgumentException("Params may not be null");  
  +        }
  +        this.params = params; 
           this.httpConnectionManager = httpConnectionManager;
       }
       
  +    /**
  +     * Creates an instance of HttpClient with a user specified 
  +     * {@link HttpConnectionManager HTTP connection manager}.
  +     * 
  +     * @param httpConnectionManager The {@link HttpConnectionManager connection manager}
  +     * to use.
  +     * 
  +     * @since 2.0
  +     */
  +    public HttpClient(HttpConnectionManager httpConnectionManager) {
  +        this(new HttpClientParams(), httpConnectionManager);
  +    }
  +    
       // ----------------------------------------------------- Instance Variables
   
       /** 
  @@ -168,7 +210,10 @@
        */
       private HttpState state = new HttpState();
       
  -    private HttpClientParams params = new HttpClientParams(); 
  +    /**
  +     * The {@link HttpClientParams collection of parameters} associated with this HttpClient.
  +     */
  +    private HttpClientParams params = null; 
   
       /** 
        * The {@link HostConfiguration host configuration} associated with
  
  
  
  1.3       +60 -26    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java
  
  Index: DefaultHttpParams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultHttpParams.java	17 Sep 2003 23:29:05 -0000	1.2
  +++ DefaultHttpParams.java	23 Sep 2003 19:51:49 -0000	1.3
  @@ -63,6 +63,7 @@
   
   package org.apache.commons.httpclient.params;
   
  +import java.io.Serializable;
   import java.util.HashMap;
   
   import org.apache.commons.logging.Log;
  @@ -70,21 +71,22 @@
   
   /**
    * This class represents a collection of HTTP protocol parameters. Protocol parameters
  - * may be linked together to form a hierarchy. A parameter may be <tt>off</tt>, <tt>on</tt>
  - * or not explicitly defined. If a parameter value has not been explicitly defined, 
  - * its default value will be drawn from the upper level collection of parameters.
  - *   
  + * may be linked together to form a hierarchy. If a particular parameter value has not been
  + * explicitly defined in the collection itself, its value will be drawn from the parent 
  + * collection of parameters.
  + * 
    * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
    * 
    * @version $Revision$
    *
    */
   
  -public class DefaultHttpParams implements HttpParams {
  +public class DefaultHttpParams implements HttpParams, Serializable, Cloneable {
   
       /** Log object for this class. */
       private static final Log LOG = LogFactory.getLog(DefaultHttpParams.class);
   
  +    /** HttpParams class factory. */
       private static HttpParamsFactory httpParamsFactory = new DefaultHttpParamsFactory();
   
       /**
  @@ -115,28 +117,35 @@
       /** The set of default values to defer to */
       private HttpParams defaults = null;
   
  -    /** Hash map of HTTP parameters that this object contains */
  +    /** Hash map of HTTP parameters that this collection contains */
       private HashMap parameters = null;
       
  +    /**
  +     * Creates a new collection of parameters with the given parent. 
  +     * The collection will defer to its parent for a default value 
  +     * if a particular parameter is not explicitly set in the collection
  +     * itself.
  +     * 
  +     * @param defaults the parent collection to defer to, if a parameter
  +     * is not explictly set in the collection itself.
  +     */
       public DefaultHttpParams(final HttpParams defaults) {
           super();
           this.defaults = defaults; 
       }
       
       /**
  -     * Initializes this class with defaults set to the value returned from 
  -     * <code>DefaultHttpParams.getDefaultParams()</code>.
  -     *
  +     * Creates a new collection of parameters with the collection returned
  +     * by {@link #getDefaultParams()} as a parent. The collection will defer
  +     * to its parent for a default value if a particular parameter is not 
  +     * explicitly set in the collection itself.
  +     * 
        * @see #getDefaultParams()
        */
       public DefaultHttpParams() {
           this(getDefaultParams());
       }
       
  -    /** 
  -     * Returns reference to 
  -     * 
  -     */
       public synchronized HttpParams getDefaults() {
           return this.defaults;
       }
  @@ -176,14 +185,19 @@
           }
       }
       
  +    /**
  +     * Assigns the value to all the parameter with the given names
  +     * 
  +     * @param names array of parameter name
  +     * @param value parameter value
  +     */ 
       public synchronized void setParameters(final String[] names, final Object value) {
           for (int i = 0; i < names.length; i++) {
               setParameter(names[i], value);
           }
       }
   
  -    public long getLongParameter(final String name, long defaultValue) 
  -      throws ClassCastException {
  +    public long getLongParameter(final String name, long defaultValue) { 
           Object param = getParameter(name);
           if (param == null) {
               return defaultValue;
  @@ -195,8 +209,7 @@
           setParameter(name, new Long(value));
       }
   
  -    public int getIntParameter(final String name, int defaultValue) 
  -      throws ClassCastException {
  +    public int getIntParameter(final String name, int defaultValue) { 
           Object param = getParameter(name);
           if (param == null) {
               return defaultValue;
  @@ -208,8 +221,7 @@
           setParameter(name, new Integer(value));
       }
   
  -    public double getDoubleParameter(final String name, double defaultValue) 
  -      throws ClassCastException {
  +    public double getDoubleParameter(final String name, double defaultValue) { 
           Object param = getParameter(name);
           if (param == null) {
               return defaultValue;
  @@ -221,8 +233,7 @@
           setParameter(name, new Double(value));
       }
   
  -    public boolean getBooleanParameter(final String name, boolean defaultValue) 
  -      throws ClassCastException {
  +    public boolean getBooleanParameter(final String name, boolean defaultValue) { 
           Object param = getParameter(name);
           if (param == null) {
               return defaultValue;
  @@ -239,6 +250,29 @@
       }
           
       public boolean isParameterFalse(final String name) {
  -        return !getBooleanParameter(name, true);
  +        return !getBooleanParameter(name, false);
  +    }
  +
  +    /**
  +     * Removes all parameters from this collection. 
  +     */
  +    public void clear() {
  +        this.parameters = null;
  +    }
  +
  +    /**
  +     * Clones this collection of parameters. Please note that paramter values
  +     * themselves are not cloned. 
  +     * 
  +     * @see java.io.Serializable
  +     * @see java.lang.Object#clone()
  +     */
  +    public Object clone() throws CloneNotSupportedException
  +    {
  +        DefaultHttpParams clone = (DefaultHttpParams)super.clone();
  +        if (this.parameters != null) {
  +            clone.parameters = (HashMap)this.parameters.clone(); 
  +        }
  +        return clone;
       }
   }
  
  
  
  1.2       +131 -17   jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpClientParams.java
  
  Index: HttpClientParams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpClientParams.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpClientParams.java	11 Sep 2003 20:08:33 -0000	1.1
  +++ HttpClientParams.java	23 Sep 2003 19:51:49 -0000	1.2
  @@ -66,74 +66,195 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  +/**
  + * This class represents a collection of HTTP protocol parameters applicable to 
  + * {@link org.apache.commons.httpclient.HttpClient instances of HttpClient}. 
  + * Protocol parameters may be linked together to form a hierarchy. If a particular 
  + * parameter value has not been explicitly defined in the collection itself, its 
  + * value will be drawn from the parent collection of parameters.
  + * 
  + * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
  + * 
  + * @version $Revision$
  + */
   public class HttpClientParams extends HttpMethodParams {
   
       /** Log object for this class. */
       private static final Log LOG = LogFactory.getLog(HttpParams.class);
   
  +    /**
  +     * Sets the socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the 
  +     * timeout for waiting for data. A timeout value of zero is interpreted as an 
  +     * infinite timeout.
  +     * This parameter expects a value of type {@link Integer}.
  +     */
       public static final String SO_TIMEOUT = "http.socket.timeout"; 
  +
  +    /**
  +     * Sets the timeout until a connection is etablished. A value of zero 
  +     * means the timeout is not used. The default value is zero.
  +     * This parameter expects a value of type {@link Integer}.
  +     */
       public static final String CONNECTION_TIMEOUT = "http.connection.timeout"; 
  +
  +    /**
  +     * Sets the timeout in milliseconds used when retrieving an 
  +     * {@link org.apache.commons.httpclient.HttpConnection HTTP connection} from the
  +     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}.
  +     * This parameter expects a value of type {@link Long}.
  +     */ 
       public static final String CONNECTION_MANAGER_TIMEOUT = "http.connection-manager.timeout"; 
  +
  +    /**
  +     * Defines the default 
  +     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
  +     * class.
  +     * This parameter expects a value of type {@link Class}.
  +     */ 
       public static final String CONNECTION_MANAGER_CLASS = "http.connection-manager.class"; 
  +
  +    /**
  +     * Defines whether authentication should be attempted preemptively.
  +     * This parameter expects a value of type {@link Boolean}.
  +     */
       public static final String PREEMPTIVE_AUTHENTICATION = "http.authentication.preemptive";
  +
  +    /**
  +     * Defines whether relative redirects should be rejected.
  +     * This parameter expects a value of type {@link Boolean}.
  +     */
       public static final String REJECT_RELATIVE_REDIRECT = "http.protocol.reject-relative-redirect"; 
   
       /**
  +     * Creates a new collection of parameters with the collection returned
  +     * by {@link #getDefaultParams()} as a parent. The collection will defer
  +     * to its parent for a default value if a particular parameter is not 
  +     * explicitly set in the collection itself.
        * 
  +     * @see #getDefaultParams()
        */
       public HttpClientParams() {
           super();
       }
   
       /**
  -     * @param defaults
  +     * Creates a new collection of parameters with the given parent. 
  +     * The collection will defer to its parent for a default value 
  +     * if a particular parameter is not explicitly set in the collection
  +     * itself.
  +     * 
  +     * @param defaults the parent collection to defer to, if a parameter
  +     * is not explictly set in the collection itself.
  +     *
  +     * @see #getDefaultParams()
        */
       public HttpClientParams(HttpParams defaults) {
           super(defaults);
       }
   
  +    /**
  +     * Returns the socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the 
  +     * timeout for waiting for data. A timeout value of zero is interpreted as an 
  +     * infinite timeout.
  +     *
  +     * @return timeout in milliseconds
  +     */
       public int getSoTimeout() {
           return getIntParameter(SO_TIMEOUT, 0);
       }
   
  -
  +    /**
  +     * Sets the socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the 
  +     * timeout for waiting for data. A timeout value of zero is interpreted as an 
  +     * infinite timeout.
  +     *
  +     * @param timeout Timeout in milliseconds
  +     */
       public void setSoTimeout(int timeout) {
           setIntParameter(SO_TIMEOUT, timeout);
       }
   
  -
  +    /**
  +     * Returns the timeout until a connection is etablished. A value of zero 
  +     * means the timeout is not used. The default value is zero.
  +     * 
  +     * @return timeout in milliseconds.
  +     */
       public int getConnectionTimeout() {
           return getIntParameter(CONNECTION_TIMEOUT, 0);
       }
   
  -
  +    /**
  +     * Sets the timeout until a connection is etablished. A value of zero 
  +     * means the timeout is not used. The default value is zero.
  +     * 
  +     * @param timeout Timeout in milliseconds.
  +     */
       public void setConnectionTimeout(int timeout) {
           setIntParameter(CONNECTION_TIMEOUT, timeout);
       }
   
  -
  +    /**
  +     * Returns the timeout in milliseconds used when retrieving an 
  +     * {@link org.apache.commons.httpclient.HttpConnection HTTP connection} from the
  +     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}.
  +     * 
  +     * @return timeout in milliseconds.
  +     */ 
       public long getConnectionManagerTimeout() {
           return getLongParameter(CONNECTION_MANAGER_TIMEOUT, 0);
       }
   
  -
  +    /**
  +     * Sets the timeout in milliseconds used when retrieving an 
  +     * {@link org.apache.commons.httpclient.HttpConnection HTTP connection} from the
  +     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}.
  +     * 
  +     * @param timeout the timeout in milliseconds
  +     */ 
       public void setConnectionManagerTimeout(long timeout) {
           setLongParameter(CONNECTION_MANAGER_TIMEOUT, timeout);
       }
   
  +    /**
  +     * Returns the default 
  +     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
  +     * class.
  +     * @return {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
  +     * factory class.
  +     */ 
       public Class getConnectionManagerClass() {
           return (Class) getParameter(CONNECTION_MANAGER_CLASS);
       }
   
  +    /**
  +     * Sets {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
  +     * class to be used der default.
  +     * @param clazz 
  +     *  {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
  +     *  factory class.
  +     */ 
       public void setConnectionManagerClass(Class clazz) {
           setParameter(CONNECTION_MANAGER_CLASS, clazz);
       }
       
  +    /**
  +     * Returns <tt>true</tt> if authentication should be attempted preemptively, 
  +     * <tt>false</tt> otherwise.
  +     * 
  +     * @return <tt>true</tt> if authentication should be attempted preemptively,
  +     *   <tt>false</tt> otherwise.
  +     */
       public boolean isAuthenticationPreemptive() {
           return getBooleanParameter(PREEMPTIVE_AUTHENTICATION, false); 
       }
   
  -
  +    /**
  +     * Sets whether authentication should be attempted preemptively.
  +     * 
  +     * @param value <tt>true</tt> if authentication should be attempted preemptively,
  +     *   <tt>false</tt> otherwise.
  +     */
       public void setAuthenticationPreemptive(boolean value) {
           setBooleanParameter(PREEMPTIVE_AUTHENTICATION, value); 
       }
  @@ -153,11 +274,4 @@
           super.makeLenient();
           setParameters(PROTOCOL_STRICTNESS_PARAMETERS, new Boolean(false));
       }
  -
  -
  -    public void makeDefault() {
  -        super.makeDefault();
  -        setParameters(PROTOCOL_STRICTNESS_PARAMETERS, null);
  -    }
  -    
   }
  
  
  
  1.2       +90 -12    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java
  
  Index: HttpMethodParams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpMethodParams.java	11 Sep 2003 20:08:33 -0000	1.1
  +++ HttpMethodParams.java	23 Sep 2003 19:51:49 -0000	1.2
  @@ -67,33 +67,99 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  +/**
  + * This class represents a collection of HTTP protocol parameters applicable to 
  + * {@link org.apache.commons.httpclient.HttpMethod HTTP methods}. Protocol 
  + * parameters may be linked together to form a hierarchy. If a particular 
  + * parameter value has not been explicitly defined in the collection itself, 
  + * its value will be drawn from the parent collection of parameters.
  + * 
  + * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
  + * 
  + * @version $Revision$
  + */
   public class HttpMethodParams extends DefaultHttpParams {
   
       /** Log object for this class. */
       private static final Log LOG = LogFactory.getLog(HttpMethodParams.class);
   
  +    /**
  +     * Defines the content of the <tt>User-Agent</tt> header used by  
  +     * {@link org.apache.commons.httpclient.HttpMethod HTTP methods}.
  +     * This parameter expects a value of type {@link String}.
  +     */
       public static final String USER_AGENT = "http.useragent"; 
  +
  +    /**
  +     * Defines the {@link HttpVersion HTTP protocol version} used by  
  +     * {@link org.apache.commons.httpclient.HttpMethod HTTP methods} per
  +     * default.
  +     * This parameter expects a value of type {@link HttpVersion}.
  +     */
       public static final String PROTOCOL_VERSION = "http.protocol.version"; 
   
  +    /**
  +     * Defines whether {@link org.apache.commons.httpclient.HttpMethod HTTP methods} should
  +     * reject ambiguous {@link org.apache.commons.httpclient.StatusLine HTTP status line}.
  +     * This parameter expects a value of type {@link Boolean}.
  +     */
       public static final String UNAMBIGUOUS_STATUS_LINE = "http.protocol.unambiguous-statusline"; 
  +
  +    /**
  +     * Defines whether {@link org.apache.commons.httpclient.Cookie cookies} should be put on 
  +     * a single {@link org.apache.commons.httpclient.Header response header}.
  +     * This parameter expects a value of type {@link Boolean}.
  +     */
       public static final String SINGLE_COOKIE_HEADER = "http.protocol.single-cookie-header"; 
  +
  +    /**
  +     * Defines whether responses with an invalid <tt>Transfer-Encoding</tt> header should be 
  +     * rejected.
  +     * This parameter expects a value of type {@link Boolean}.
  +     */
       public static final String STRICT_TRANSFER_ENCODING = "http.protocol.strict-transfer-encoding"; 
  +
  +    /**
  +     * Defines whether the content body sent in response to 
  +     * {@link org.apache.commons.httpclient.methods.HeadMethod} should be rejected.
  +     * This parameter expects a value of type {@link Boolean}.
  +     */
       public static final String REJECT_HEAD_BODY = "http.protocol.reject-head-body"; 
   
       /**
  +     * Creates a new collection of parameters with the collection returned
  +     * by {@link #getDefaultParams()} as a parent. The collection will defer
  +     * to its parent for a default value if a particular parameter is not 
  +     * explicitly set in the collection itself.
        * 
  +     * @see #getDefaultParams()
        */
       public HttpMethodParams() {
           super();
       }
   
       /**
  -     * @param defaults
  +     * Creates a new collection of parameters with the given parent. 
  +     * The collection will defer to its parent for a default value 
  +     * if a particular parameter is not explicitly set in the collection
  +     * itself.
  +     * 
  +     * @param defaults the parent collection to defer to, if a parameter
  +     * is not explictly set in the collection itself.
  +     *
  +     * @see #getDefaultParams()
        */
       public HttpMethodParams(HttpParams defaults) {
           super(defaults);
       }
   
  +    /**
  +     * Returns {@link HttpVersion HTTP protocol version} to be used by the 
  +     * {@link org.apache.commons.httpclient.HttpMethod HTTP methods} that 
  +     * this collection of parameters applies to. 
  +     *
  +     * @return {@link HttpVersion HTTP protocol version}
  +     */
       public HttpVersion getVersion() { 
           Object param = getParameter(PROTOCOL_VERSION);
           if (param == null) {
  @@ -102,7 +168,13 @@
           return (HttpVersion)param;
       }
       
  -    
  +    /**
  +     * Assigns the {@link HttpVersion HTTP protocol version} to be used by the 
  +     * {@link org.apache.commons.httpclient.HttpMethod HTTP methods} that 
  +     * this collection of parameters applies to. 
  +     *
  +     * @param version the {@link HttpVersion HTTP protocol version}
  +     */
       public void setVersion(HttpVersion version) {
           setParameter(PROTOCOL_VERSION, version);
       }
  @@ -115,19 +187,25 @@
           REJECT_HEAD_BODY
       };
       
  -    
  +    /**
  +     * Makes the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} 
  +     * strictly follow the HTTP protocol specification (RFC 2616 and other relevant RFCs).
  +     * It must be noted that popular HTTP agents have different degree of HTTP protocol 
  +     * compliance and some HTTP serves are programmed to expect the behaviour that does not 
  +     * strictly adhere to the HTTP specification.  
  +     */
       public void makeStrict() {
           setParameters(PROTOCOL_STRICTNESS_PARAMETERS, new Boolean(true));
       }
   
  -
  +    /**
  +     * Makes the {@link org.apache.commons.httpclient.HttpMethod HTTP methods}
  +     * attempt to mimic the exact behaviour of commonly used HTTP agents, 
  +     * which many HTTP servers expect, even though such behaviour may violate   
  +     * the HTTP protocol specification (RFC 2616 and other relevant RFCs).
  +     */
       public void makeLenient() {
           setParameters(PROTOCOL_STRICTNESS_PARAMETERS, new Boolean(false));
  -    }
  -
  -
  -    public void makeDefault() {
  -        setParameters(PROTOCOL_STRICTNESS_PARAMETERS, null);
       }
   
   }
  
  
  
  1.2       +144 -7    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpParams.java
  
  Index: HttpParams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpParams.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpParams.java	11 Sep 2003 20:08:33 -0000	1.1
  +++ HttpParams.java	23 Sep 2003 19:51:49 -0000	1.2
  @@ -65,9 +65,9 @@
   
   /**
    * This interface represents a collection of HTTP protocol parameters. Protocol parameters
  - * may be linked together to form a hierarchy. A parameter may be <tt>off</tt>, <tt>on</tt>
  - * or not explicitly defined. If a parameter value has not been explicitly defined, 
  - * its default value will be drawn from the upper level collection of parameters.
  + * may be linked together to form a hierarchy. If a particular parameter value has not been
  + * explicitly defined in the collection itself, its value will be drawn from the parent 
  + * collection of parameters.
    *   
    * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
    * 
  @@ -77,32 +77,169 @@
   
   public interface HttpParams {
   
  +    /** 
  +     * Returns the parent collection that this collection will defer to
  +     * for a default value if a particular parameter is not explicitly 
  +     * set in the collection itself
  +     * 
  +     * @return the parent collection to defer to, if a particular parameter
  +     * is not explictly set in the collection itself.
  +     * 
  +     * @see #setDefaults(HttpParams)
  +     */
       public HttpParams getDefaults();
   
  +    /** 
  +     * Assigns the parent collection that this collection will defer to
  +     * for a default value if a particular parameter is not explicitly 
  +     * set in the collection itself
  +     * 
  +     * @param params the parent collection to defer to, if a particular 
  +     * parameter is not explictly set in the collection itself.
  +     * 
  +     * @see #getDefaults()
  +     */
       public void setDefaults(final HttpParams params);
       
  +    /** 
  +     * Returns a parameter value with the given name. If the parameter is
  +     * not explicitly defined in this collection, its value will be drawn 
  +     * from a higer level collection at which this parameter is defined.
  +     * If the parameter is not explicitly set anywhere up the hierarchy,
  +     * <tt>null</tt> value is returned.  
  +     * 
  +     * @param name the parent name.
  +     * 
  +     * @return an object that represents the value of the parameter.
  +     * 
  +     * @see #setParameter(String, Object)
  +     */
       public Object getParameter(final String name);
   
  +    /**
  +     * Assigns the value to the parameter with the given name
  +     * 
  +     * @param name parameter name
  +     * @param value parameter value
  +     */ 
       public void setParameter(final String name, final Object value);
       
  +    /** 
  +     * Returns a {@link Long} parameter value with the given name. 
  +     * If the parameter is not explicitly defined in this collection, its 
  +     * value will be drawn from a higer level collection at which this parameter 
  +     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  +     * the default value is returned.  
  +     * 
  +     * @param name the parent name.
  +     * @param defaultValue the default value.
  +     * 
  +     * @return a {@link Long} that represents the value of the parameter.
  +     * 
  +     * @see #setLongParameter(String, long)
  +     */
       public long getLongParameter(final String name, long defaultValue); 
       
  +    /**
  +     * Assigns a {@link Long} to the parameter with the given name
  +     * 
  +     * @param name parameter name
  +     * @param value parameter value
  +     */ 
       public void setLongParameter(final String name, long value);
   
  +    /** 
  +     * Returns an {@link Integer} parameter value with the given name. 
  +     * If the parameter is not explicitly defined in this collection, its 
  +     * value will be drawn from a higer level collection at which this parameter 
  +     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  +     * the default value is returned.  
  +     * 
  +     * @param name the parent name.
  +     * @param defaultValue the default value.
  +     * 
  +     * @return a {@link Integer} that represents the value of the parameter.
  +     * 
  +     * @see #setIntParameter(String, int)
  +     */
       public int getIntParameter(final String name, int defaultValue); 
       
  +    /**
  +     * Assigns an {@link Integer} to the parameter with the given name
  +     * 
  +     * @param name parameter name
  +     * @param value parameter value
  +     */ 
       public void setIntParameter(final String name, int value);
   
  +    /** 
  +     * Returns a {@link Double} parameter value with the given name. 
  +     * If the parameter is not explicitly defined in this collection, its 
  +     * value will be drawn from a higer level collection at which this parameter 
  +     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  +     * the default value is returned.  
  +     * 
  +     * @param name the parent name.
  +     * @param defaultValue the default value.
  +     * 
  +     * @return a {@link Double} that represents the value of the parameter.
  +     * 
  +     * @see #setDoubleParameter(String, double)
  +     */
       public double getDoubleParameter(final String name, double defaultValue); 
       
  +    /**
  +     * Assigns a {@link Double} to the parameter with the given name
  +     * 
  +     * @param name parameter name
  +     * @param value parameter value
  +     */ 
       public void setDoubleParameter(final String name, double value);
   
  +    /** 
  +     * Returns a {@link Boolean} parameter value with the given name. 
  +     * If the parameter is not explicitly defined in this collection, its 
  +     * value will be drawn from a higer level collection at which this parameter 
  +     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
  +     * the default value is returned.  
  +     * 
  +     * @param name the parent name.
  +     * @param defaultValue the default value.
  +     * 
  +     * @return a {@link Boolean} that represents the value of the parameter.
  +     * 
  +     * @see #setBooleanParameter(String, boolean)
  +     */
       public boolean getBooleanParameter(final String name, boolean defaultValue); 
       
  +    /**
  +     * Assigns a {@link Boolean} to the parameter with the given name
  +     * 
  +     * @param name parameter name
  +     * @param value parameter value
  +     */ 
       public void setBooleanParameter(final String name, boolean value);
   
  +    /**
  +     * Returns <tt>true</tt> if the parameter is set and is <tt>true</tt>, <tt>false</tt>
  +     * otherwise.
  +     * 
  +     * @param name parameter name
  +     * 
  +     * @return <tt>true</tt> if the parameter is set and is <tt>true</tt>, <tt>false</tt>
  +     * otherwise.
  +     */
       public boolean isParameterTrue(final String name);
           
  +    /**
  +     * Returns <tt>true</tt> if the parameter is either not set or is <tt>false</tt>, 
  +     * <tt>false</tt> otherwise.
  +     * 
  +     * @param name parameter name
  +     * 
  +     * @return <tt>true</tt> if the parameter is either not set or is <tt>false</tt>, 
  +     * <tt>false</tt> otherwise.
  +     */
       public boolean isParameterFalse(final String name);
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org