Hey Oleg. I'm Playing with PostMethod writing some tests. It looks really good in there, and will be even better after get rid the deprecated stuff. I had a few changes, and a few questions:

1) PostMethod.generateRequestBody()
This method just url encodes the parameters. In the 5000 lines of URI handling code, isn't there a method that url encodes an array of name value pairs? (I looked, but couldn't find one)

2) EntityEnclosingMethod
There is a useExpectHeader variable, with a setter and a getter, but it is not used for anything.

3) PostMethod.deprecated_parameters
I made this private because we might as well. Fine about the underscore in the name, makes it stand out as somthing we *want* to get rid of.

4) PostMethod.URL_ENCODED_CONTENT_TYPE
Made this public. In the case where a user is using setRequestBody(string) where the string is URL encoded they need a way to add the right header. I'm using this to simplify the tests I added too.

I made some other minor changes (mostly formatting) which are attached as a patch. Hope that its OK I committed this. I was going to consult with you first, but I commited the new test file before I realized that I was relying on one of the changes, so I had to go for the gusto.

Jandalf.


Kalnichevski, Oleg wrote:

Bug fixes:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11095
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11653
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14731

Changelog:

- Abstract EntityEnclosingMethod class has been introduced to encapsulate common behaviour of all entity enclosing methods - "Expect: 100-continue" header support
- HttpClient does not hang indefinitely if the server of origin does not return status code 100 when expected. HttpClient resumes sending request body after 3 seconds if no response is sent
- Support for chunk encoded requests in all entity enclosing methods
- Entity enclosing methods do not allow automatic redirection
- More robust (or so I'd like to hope) request content buffering logic
- PostMethod inherited from EntityEnclosingMethod class
- PutMethod inherited from EntityEnclosingMethod class
- Older methods of PostMethod dealing with url-encoded parameters deprecated in favour of new setRequestBody(NameValuePair[]) method

Feedback, critique appreciated, as always.

Jeff, Mike
I decided to not touch request body buffering as yet. The patch is getting really unwieldy. I would like to have it committed, if you confirm it does not break test cases on your systems. We can deal with smaller issues and improvements incrementally once the patch has been checked in

Cheers

Oleg

PS: The patch appears to have exceeded the allowed maximum. It has just been thrown back to me ;-) I am afraid I'll have to compress the file

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

? post_and_entity_cleanups.diff
Index: java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java,v
retrieving revision 1.1
diff -u -r1.1 EntityEnclosingMethod.java
--- java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java       1 Feb 
2003 00:01:01 -0000       1.1
+++ java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java       1 Feb 
+2003 06:33:41 -0000
@@ -2,11 +2,12 @@
  * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java,v
 1.1 2003/02/01 00:01:01 olegk Exp $
  * $Revision: 1.1 $
  * $Date: 2003/02/01 00:01:01 $
+ *
  * ====================================================================
  *
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
+ * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -85,17 +86,12 @@
  * This abstract class serves as a foundation for all HTTP methods 
  * that can enclose an entity within requests 
  *
- * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
- * @author <a href="mailto:[EMAIL PROTECTED]";>Doug Sale</a>
- * @author <a href="mailto:[EMAIL PROTECTED]";>Jeff Dever</a>
- * @author Ortwin Glück
  * @author <a href="mailto:[EMAIL PROTECTED]";>Oleg Kalnichevski</a>
  * 
  * @since 2.0beta1
  */
+public abstract class EntityEnclosingMethod extends GetMethod {
 
-public abstract class EntityEnclosingMethod extends GetMethod
-{
     // ----------------------------------------- Static variables/initializers
 
     /**
@@ -127,6 +123,7 @@
      */
     private int requestContentLength = CONTENT_LENGTH_AUTO;
 
+    
     private boolean useExpectHeader = true;
     
     // ----------------------------------------------------------- Constructors
@@ -161,8 +158,8 @@
      *
      * @since 2.0
      */
-    public EntityEnclosingMethod(String uti, String tempDir) {
-        super(uti, tempDir);
+    public EntityEnclosingMethod(String uri, String tempDir) {
+        super(uri, tempDir);
         setFollowRedirects(false);
     }
 
@@ -182,7 +179,8 @@
 
 
     /**
-     * Entity enclosing requests cannot be redirected without user intervention 
according to RFC 2616.
+     * Entity enclosing requests cannot be redirected without user intervention
+     * according to RFC 2616.
      *
      * @return <code>false</code>.
      *
@@ -194,11 +192,10 @@
 
 
     /**
-     * Entity enclosing requests cannot be redirected without user intervention 
according to RFC 2616.
+     * Entity enclosing requests cannot be redirected without user intervention 
+     * according to RFC 2616.
      *
      * @param followRedirects must always be <code>false</code>
-     * 
-     * @throws IllegalArgumentException if <code>true</code> is given
      */
     public void setFollowRedirects(boolean followRedirects) {
         if (followRedirects == true) {
@@ -216,17 +213,15 @@
      * Returns the useExpectHeader.
      * @return boolean
      */
-    public boolean getUseExpectHeader()
-    {
+    public boolean getUseExpectHeader() {
         return this.useExpectHeader;
     }
 
     /**
      * Sets the useExpectHeader.
-     * @param useExpectHeader The useExpectHeader to set
+     * @param value The useExpectHeader to set
      */
-    public void setUseExpectHeader(boolean value)
-    {
+    public void setUseExpectHeader(boolean value) {
         this.useExpectHeader = value;
     }
 
@@ -249,7 +244,6 @@
      *        If CONTENT_LENGTH_AUTO is specified the request will be buffered
      *        before it is sent over the network.
      *
-     * @since 2.0
      */
     public void setRequestContentLength(int length) {
         LOG.trace("enter EntityEnclosingMethod.setRequestContentLength(int)");
@@ -261,8 +255,6 @@
      * to return the length of the request body.
      *
      * @return number of bytes in the request body
-     *
-     * @since 2.0
      */
     protected int getRequestContentLength() {
         LOG.trace("enter EntityEnclosingMethod.getRequestContentLength()");
@@ -271,20 +263,14 @@
             return this.requestContentLength;
         }
         bufferContent();
-        if (this.buffer != null) {
-            return this.buffer.length;
-        }
-        else {
-            return 0;
-        }
+
+        return (this.buffer == null) ? 0 : this.buffer.length;
     }
 
     /**
      * Sets the request body to be the specified inputstream.
      *
      * @param body Request body content as {@link java.io.InputStream}
-     *
-     * @since 2.0
      */
     public void setRequestBody(InputStream body) {
         LOG.trace("enter EntityEnclosingMethod.setRequestBody(InputStream)");
@@ -296,17 +282,12 @@
      * Gets the request body as a stream.
      *
      * @return The request body {@link java.io.InputStream} if it has been set.
-     *
-     * @throws IllegalStateException if request body is not buferred
-     * 
-     * @since 2.0
      */
     public InputStream getRequestBody() {
         LOG.trace("enter EntityEnclosingMethod.getRequestBody()");
         if (this.buffer != null) {
             return new ByteArrayInputStream(this.buffer); 
-        }
-        else {
+        } else {
             return this.requestBodyStream;
         }
     }
@@ -315,8 +296,6 @@
      * Sets the request body to be the specified string.
      *
      * @param body Request body content as a string
-     *
-     * @since 2.0
      */
     public void setRequestBody(String body) {
         LOG.trace("enter EntityEnclosingMethod.setRequestBody(String)");
@@ -330,50 +309,46 @@
     }
 
     /**
-     * Gets the request body as a string.
+     * Gets the request body as a String.
      *
      * @return the request body as a string
      * 
      * @throws IOException when i/o errors occur reading the request
-     * @throws IllegalStateException if request body is not buferred
-     *
-     * @since 2.0
      */
-
     public String getRequestBodyAsString() throws IOException {
         LOG.trace("enter EntityEnclosingMethod.getRequestBodyAsString()");
+
         Reader instream = null;
         try {
             instream = new InputStreamReader(getRequestBody(), getRequestCharSet());
-        }
-        catch(UnsupportedEncodingException e) {
+        } catch (UnsupportedEncodingException e) {
             if (LOG.isWarnEnabled()) {
                 LOG.warn("Unsupported encoding: " + e.getMessage());
             }
             instream = new InputStreamReader(getRequestBody());
         }
+
         StringBuffer buffer = new StringBuffer();
         char[] tmp = new char[4096];
         int l = 0;
-        while((l = instream.read(tmp)) >= 0) {
+        while ((l = instream.read(tmp)) >= 0) {
             buffer.append(tmp, 0, l);
         }
+
         return buffer.toString();
     }
 
 
     /**
-     * Override the method of {@link HttpMethodBase}
-     * to set the <tt>Expect</tt> header if it has
-     * not already been set, in addition to the "standard"
-     * set of headers.
+     * Set the <tt>Expect</tt> header if it has not already been set, 
+     * in addition to the "standard" set of headers.
+     *
+     * @param state the client state
+     * @param conn the connection to write to
      *
      * @throws HttpException when a protocol error occurs or state is invalid
      * @throws IOException when i/o errors occur reading the response
-     * 
-     * @since 2.0
      */
-
     protected void addRequestHeaders(HttpState state, HttpConnection conn)
     throws IOException, HttpException {
         LOG.trace("enter EntityEnclosingMethod.addRequestHeaders(HttpState, 
HttpConnection)");
@@ -384,7 +359,7 @@
 
         super.addRequestHeaders(state, conn);
         // Send expectation header, provided there's something to be sent
-        if(isHttp11() && getUseExpectHeader() && (this.requestBodyStream != null)) {
+        if (isHttp11() && getUseExpectHeader() && (this.requestBodyStream != null)) {
             if (getRequestHeader("Expect") == null) {
                 setRequestHeader("Expect", "100-continue");
             }
@@ -402,8 +377,6 @@
      * @return <tt>true</tt>
      * @throws IOException when i/o errors occur reading the response
      * @throws HttpException when a protocol error occurs or state is invalid
-     *
-     * @since 2.0
      */
     protected boolean writeRequestBody(HttpState state, HttpConnection conn)
     throws IOException, HttpException {
@@ -415,7 +388,7 @@
                 LOG.debug("Expecting response");
                 return false;
             }
-            if(getStatusLine().getStatusCode() != HttpStatus.SC_CONTINUE) {
+            if (getStatusLine().getStatusCode() != HttpStatus.SC_CONTINUE) {
                 LOG.debug("Expecting 100-continue");
                 return false;
             }
@@ -459,7 +432,7 @@
         }
         // This is hardly the most elegant solution to closing chunked stream
         if (outstream instanceof ChunkedOutputStream) {
-            ((ChunkedOutputStream)outstream).writeClosingChunk();
+            ((ChunkedOutputStream) outstream).writeClosingChunk();
         }
         if ((contentLength > 0) && (total < contentLength)) {
             throw new IOException("Unexpected end of input stream after "
@@ -472,25 +445,20 @@
     /**
      * Override method of {@link org.apache.commons.httpclient.HttpMethodBase}
      * to clear my request body.
-     *
-     * @since 2.0
      */
     public void recycle() {
         LOG.trace("enter EntityEnclosingMethod.recycle()");
-        super.recycle();
         this.requestContentLength = CONTENT_LENGTH_AUTO;
         this.requestBodyStream = null;
         this.buffer = null;
         this.repeatCount = 0;
+        super.recycle();
     }
 
     /**
      * Buffers the request body and calculates the content length. If the
      * method was called earlier it returns immediately.
-     *
-     * @since 2.0
      */
-    
     protected void bufferContent() {
         LOG.trace("enter EntityEnclosingMethod.bufferContent()");
 
@@ -510,9 +478,7 @@
             this.buffer = tmp.toByteArray();
             this.requestBodyStream = null;
         } catch (IOException e) {
-            if (LOG.isErrorEnabled()) {
-                LOG.error(e.toString(), e );
-            }
+            LOG.error(e.getMessage(), e);
             this.buffer = null;
             this.requestBodyStream = null;
         }
Index: java/org/apache/commons/httpclient/methods/PostMethod.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
retrieving revision 1.35
diff -u -r1.35 PostMethod.java
--- java/org/apache/commons/httpclient/methods/PostMethod.java  31 Jan 2003 23:23:16 
-0000      1.35
+++ java/org/apache/commons/httpclient/methods/PostMethod.java  1 Feb 2003 06:33:43 
+-0000
@@ -2,6 +2,7 @@
  * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
 1.35 2003/01/31 23:23:16 olegk Exp $
  * $Revision: 1.35 $
  * $Date: 2003/01/31 23:23:16 $
+ *
  * ====================================================================
  *
  * The Apache Software License, Version 1.1
@@ -65,7 +66,6 @@
 import java.io.InputStream;
 import java.util.Vector;
 import java.util.Iterator;
-import java.util.List;
 
 import org.apache.commons.httpclient.HttpState;
 import org.apache.commons.httpclient.HttpConnection;
@@ -117,7 +117,7 @@
     // -------------------------------------------------------------- Constants
 
     /** Log object for this class. */
-    private static final Log log = LogFactory.getLog(PostMethod.class);
+    private static final Log LOG = LogFactory.getLog(PostMethod.class);
 
     /** Custom content encoding. */
     private static final int CUSTOM_CONTENT = 0;
@@ -126,14 +126,18 @@
     private static final int URL_ENCODED_CONTENT = 1;
     
     /** My content encoding. */
-    private int contentEnconding = CUSTOM_CONTENT;
+    private int contentEncoding = CUSTOM_CONTENT;
 
     /** The Content-Type header for www-form-urlcoded. */
-    static final Header URL_ENCODED_CONTENT_TYPE = new Header("Content-Type",
+    public static final Header URL_ENCODED_CONTENT_TYPE = new Header("Content-Type",
         "application/x-www-form-urlencoded");
 
-    /** The buffered request body consisting of <code>NameValuePair</code>s */
-    protected Vector deprecated_parameters = new Vector();
+    /** 
+     * The buffered request body consisting of <code>NameValuePair</code>s. 
+     * @deprecated Parameters will not be buffered in the future but converted
+     * into an InputStream immeadiately.
+     */
+    private Vector deprecated_parameters = new Vector();
 
     // ----------------------------------------------------------- Constructors
 
@@ -165,8 +169,8 @@
      *
      * @since 1.0
      */
-    public PostMethod(String uti, String tempDir) {
-        super(uti, tempDir);
+    public PostMethod(String uri, String tempDir) {
+        super(uri, tempDir);
     }
 
     /**
@@ -207,7 +211,7 @@
      * @deprecated use {@link #setRequestBody(NameValuePair[])}.
      */
     public void setParameter(String parameterName, String parameterValue) {
-        log.trace("enter PostMethod.setParameter(String, String)");
+        LOG.trace("enter PostMethod.setParameter(String, String)");
 
         removeParameter(parameterName, parameterValue);
         addParameter(parameterName, parameterValue);
@@ -228,7 +232,7 @@
      * {@link #getRequestBodyAsString()}.
      */
     public NameValuePair getParameter(String paramName) {
-        log.trace("enter PostMethod.getParameter(String)");
+        LOG.trace("enter PostMethod.getParameter(String)");
 
         if (paramName == null) {
             return null;
@@ -250,7 +254,7 @@
      * Gets the parameters currently added to the PostMethod. If there are no
      * parameters, a valid array is returned with zero elements. The returned
      * array object contains an array of pointers to  the internal data
-     * members. TODO: is it ok to return internal data?
+     * members.
      *
      * @return An array of the current parameters
      *
@@ -260,7 +264,7 @@
      * {@link #getRequestBodyAsString()}.
      */
     public NameValuePair[] getParameters() {
-        log.trace("enter PostMethod.getParameters()");
+        LOG.trace("enter PostMethod.getParameters()");
 
         int numPairs = deprecated_parameters.size();
         Object[] objectArr = deprecated_parameters.toArray();
@@ -285,8 +289,9 @@
      * 
      * @deprecated use {@link #setRequestBody(NameValuePair[])}.
      */
-    public void addParameter(String paramName, String paramValue) {
-        log.trace("enter PostMethod.addParameter(String, String)");
+    public void addParameter(String paramName, String paramValue) 
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.addParameter(String, String)");
 
         if ((paramName == null) || (paramValue == null)) {
             throw new IllegalArgumentException(
@@ -309,8 +314,9 @@
      * 
      * @deprecated use {@link #setRequestBody(NameValuePair[])}.
      */
-    public void addParameter(NameValuePair param) {
-        log.trace("enter PostMethod.addParameter(NameValuePair)");
+    public void addParameter(NameValuePair param) 
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.addParameter(NameValuePair)");
 
         if (param == null) {
             throw new IllegalArgumentException("NameValuePair may not be null");
@@ -330,10 +336,10 @@
      * @deprecated use {@link #setRequestBody(NameValuePair[])}.
      */
     public void addParameters(NameValuePair[] parameters) {
-        log.trace("enter PostMethod.addParameters(NameValuePair[])");
+        LOG.trace("enter PostMethod.addParameters(NameValuePair[])");
 
         if (parameters == null) {
-            log.warn("Attempt to addParameters(null) ignored");
+            LOG.warn("Attempt to addParameters(null) ignored");
         } else {
             for (int i = 0; i < parameters.length; i++) {
                 addParameter(parameters[i]);
@@ -357,8 +363,9 @@
      * 
      * @deprecated use {@link #setRequestBody(NameValuePair[])}.
      */
-    public boolean removeParameter(String paramName) {
-        log.trace("enter PostMethod.removeParameter(String)");
+    public boolean removeParameter(String paramName) 
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.removeParameter(String)");
 
         if (paramName == null) {
             throw new IllegalArgumentException(
@@ -395,8 +402,9 @@
      * 
      * @deprecated use {@link #setRequestBody(NameValuePair[])}.
      */
-    public boolean removeParameter(String paramName, String paramValue) {
-        log.trace("enter PostMethod.removeParameter(String, String)");
+    public boolean removeParameter(String paramName, String paramValue) 
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.removeParameter(String, String)");
 
         if (paramName == null) {
             throw new IllegalArgumentException("Parameter name may not be null");
@@ -416,48 +424,29 @@
                 return true;
             }
         }
-        setRequestBody(getParameters());
-        return false;
-    }
-
-    /**
-     * Set an Array of parameters to be used in the POST request body
-     *
-     * @param parameters The array of parameters to add.
-     *
-     * @throws IllegalArgumentException when param parameters are null
-     * 
-     * @since 2.0beta1
-     */
 
-    public void setRequestBody(NameValuePair[] parameters) {
-        log.trace("enter PostMethod.setRequestBody(NameValuePair[])");
-
-        if (parameters == null) {
-            throw new IllegalArgumentException("Array of parameters may not be null");
-        }
-        super.setRequestBody(generateRequestBody(parameters));
-        this.contentEnconding = URL_ENCODED_CONTENT;
+        return false;
     }
 
     /**
      * Encode the list of parameters into a query string.
      *
-     * @param params the list of query name and value
+     * @param parameters the list of query name and value
      *
-     * @return the query string
+     * @return url encoded form of the parameters
      *
-     * @since 2.0
+     * @throws IllegalArgumentException if parameters is null
      */
-    protected static String generateRequestBody(NameValuePair[] parameters) {
-        log.trace("enter PostMethod.generateRequestBodyAsString(NameValuePair[])");
+    protected static String generateRequestBody(NameValuePair[] parameters) 
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.generateRequestBody(NameValuePair[])");
 
         if (parameters == null) {
             throw new IllegalArgumentException("Array of parameters may not be null");
         }
         StringBuffer buff = new StringBuffer();
 
-        for(int i = 0; i < parameters.length; i++) {
+        for (int i = 0; i < parameters.length; i++) {
             if (i > 0) {
                 buff.append("&");
             }
@@ -468,58 +457,83 @@
             try {
                 queryName = URIUtil.encodeWithinQuery(parameter.getName());
             } catch (URIException urie) {
-                log.error("encoding error within query name", urie);
+                LOG.error("encoding error within query name", urie);
                 queryName = parameter.getName();
             }
+
             buff.append(queryName).append("=");
             String queryValue = null;
+
             try {
                 queryValue = URIUtil.encodeWithinQuery(parameter.getValue());
             } catch (URIException e) {
-                log.error("Encoding error within query value", e);
+                LOG.error("Encoding error within query value", e);
                 queryValue = parameter.getValue();
             }
             buff.append(queryValue);
         }
+
         return buff.toString();
     }
 
     /**
      * Sets the request body to be the specified string.
-     *
-     * <p>
      * Once this method has been invoked,  the request parameters  cannot be
      * altered until I am {@link #recycle recycled}.
-     * </p>
      *
-     * @param body Request body content as a string
+     * @param stringBody Request body content as a string
      *
-     * @since 2.0
+     * @throws IllegalArgumentException if stringBody is null
      */
-    public void setRequestBody(String body) {
-        log.trace("enter PostMethod.setRequestBody(String)");
+    public void setRequestBody(String stringBody)
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.setRequestBody(String)");
 
-        super.setRequestBody(body);
-        this.contentEnconding = CUSTOM_CONTENT;
+        if (stringBody == null) {
+            throw new IllegalArgumentException("String body not be null");
+        }
+        super.setRequestBody(stringBody);
+        this.contentEncoding = CUSTOM_CONTENT;
     }
 
     /**
      * Sets the request body to be the specified inputstream.
-     *
-     * <p>
      * Once this method has been invoked,  the request parameters  cannot be
      * altered until I am {@link #recycle recycled}.
-     * </p>
      *
-     * @param body Request body content as {@link java.io.InputStream}
+     * @param streamBody Request body content as {@link java.io.InputStream}
      *
-     * @since 2.0
+     * @throws IllegalArgumentException if streamBody is null
      */
-    public void setRequestBody(InputStream body) {
-        log.trace("enter PostMethod.getRequestBody(InputStream)");
+    public void setRequestBody(InputStream streamBody) 
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.setRequestBody(InputStream)");
 
-        super.setRequestBody(body);
-        this.contentEnconding = CUSTOM_CONTENT;
+        if (streamBody == null) {
+            throw new IllegalArgumentException("Stream body may not be null");
+        }
+        super.setRequestBody(streamBody);
+        this.contentEncoding = CUSTOM_CONTENT;
+    }
+
+    /**
+     * Set an Array of parameters to be used in the POST request body
+     *
+     * @param parametersBody The array of parameters to add.
+     *
+     * @throws IllegalArgumentException when param parameters are null
+     * 
+     * @since 2.0beta1
+     */
+    public void setRequestBody(NameValuePair[] parametersBody)
+    throws IllegalArgumentException {
+        LOG.trace("enter PostMethod.setRequestBody(NameValuePair[])");
+
+        if (parametersBody == null) {
+            throw new IllegalArgumentException("Array of parameters may not be null");
+        }
+        super.setRequestBody(generateRequestBody(parametersBody));
+        this.contentEncoding = URL_ENCODED_CONTENT;
     }
 
     /**
@@ -534,28 +548,26 @@
      *
      * @since 2.0
      */
-    
     protected void addRequestHeaders(HttpState state, HttpConnection conn)
     throws IOException, HttpException {
         super.addRequestHeaders(state, conn);
 
-        if (this.contentEnconding == URL_ENCODED_CONTENT) {
+        if (this.contentEncoding == URL_ENCODED_CONTENT) {
             //there are some parameters, so set the contentType header
             setRequestHeader(URL_ENCODED_CONTENT_TYPE);
         }
     }
 
     /**
-     * Override method of {@link org.apache.commons.httpclient.HttpMethodBase}
-     * to clear my request body.
+     * Prepare the method for reuse.
      *
      * @since 1.0
      */
     public void recycle() {
-        log.trace("enter PostMethod.recycle()");
-        super.recycle();
-        this.contentEnconding = CUSTOM_CONTENT;
+        LOG.trace("enter PostMethod.recycle()");
+        this.contentEncoding = CUSTOM_CONTENT;
         this.deprecated_parameters.clear();
+        super.recycle();
     }
 
 }
Index: java/org/apache/commons/httpclient/methods/PutMethod.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
retrieving revision 1.21
diff -u -r1.21 PutMethod.java
--- java/org/apache/commons/httpclient/methods/PutMethod.java   31 Jan 2003 23:23:16 
-0000      1.21
+++ java/org/apache/commons/httpclient/methods/PutMethod.java   1 Feb 2003 06:33:43 
+-0000
@@ -2,6 +2,7 @@
  * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
 1.21 2003/01/31 23:23:16 olegk Exp $
  * $Revision: 1.21 $
  * $Date: 2003/01/31 23:23:16 $
+ *
  * ====================================================================
  *
  * The Apache Software License, Version 1.1
Index: test-webapp/src/org/apache/commons/httpclient/ParamServlet.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/ParamServlet.java,v
retrieving revision 1.3
diff -u -r1.3 ParamServlet.java
--- test-webapp/src/org/apache/commons/httpclient/ParamServlet.java     23 Jan 2003 
22:48:49 -0000      1.3
+++ test-webapp/src/org/apache/commons/httpclient/ParamServlet.java     1 Feb 2003 
+06:33:43 -0000
@@ -68,7 +68,10 @@
 import java.util.*;
 
 public class ParamServlet extends MultiMethodServlet {
-    protected void genericService(HttpServletRequest request, HttpServletResponse 
response) throws IOException, ServletException {
+
+    protected void genericService(HttpServletRequest request, HttpServletResponse 
+response) 
+        throws IOException, ServletException {
+
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         out.println("<html>");
@@ -86,9 +89,9 @@
         out.println("</p>");
 
         out.println("<p>Parameters</p>");
-        Enumeration enum = request.getParameterNames();
-        while(enum.hasMoreElements()) {
-            String name = (String)(enum.nextElement());
+        Enumeration e = request.getParameterNames();
+        while(e.hasMoreElements()) {
+            String name = (String)(e.nextElement());
             String[] values = request.getParameterValues(name);
             if(null == values || values.length < 1) {
                 out.println("name=\"" + name + "\";value=null<br>");

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to