Ortwin Glück wrote:
Not sure what you are trying to fix here. This patch does *nothing*.

I guess you should rather close your input stream.
Oops that was the wrong patch.txt file.

I am trying to fix the missing last-chunk (The "outstream.write(tmp, 0, 0);" does it).

Find enclosed the right patch.

Odi


jean-frederic clere wrote:

Index: src/java/org/apache/commons/httpclient/methods/PostMethod.java
===================================================================
RCS file: /home/cvs/mirror/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
retrieving revision 1.27
diff -u -r1.27 PostMethod.java
--- src/java/org/apache/commons/httpclient/methods/PostMethod.java 12 Nov 2002 09:58:23 -0000 1.27
+++ src/java/org/apache/commons/httpclient/methods/PostMethod.java 21 Nov 2002 13:26:46 -0000
@@ -746,6 +746,7 @@
outstream.write(tmp, 0, i);
total += i;
}
+ outstream.write(tmp, 0, 0);
if ((this.requestContentLength > 0) && (total < this.requestContentLength)) {
throw new IOException("Unexpected end of input stream after "
+total +" bytes (expected "+ this.requestContentLength +" bytes)");



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



Index: src/java/org/apache/commons/httpclient/ChunkedOutputStream.java
===================================================================
RCS file: 
/home/cvs/mirror/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java,v
retrieving revision 1.1
diff -u -r1.1 ChunkedOutputStream.java
--- src/java/org/apache/commons/httpclient/ChunkedOutputStream.java     25 Oct 2002 
10:15:51 -0000      1.1
+++ src/java/org/apache/commons/httpclient/ChunkedOutputStream.java     21 Nov 2002 
+15:40:43 -0000
@@ -108,7 +108,7 @@
     // ----------------------------------------------------- Instance Variables
 
     /** Has this stream been closed? */
-    private boolean closed = false;
+    private boolean end = false;
 
     /** The underlying output stream to which we will write data */
     private OutputStream stream = null;
@@ -204,7 +204,12 @@
 
         byte chunkHeader[] = (Integer.toHexString(len) + "\r\n").getBytes();
         stream.write(chunkHeader, 0, chunkHeader.length);
-        stream.write(b, off, len);
+
+        if (len!=0)
+            stream.write(b, off, len);
+        else
+            end = true;
+
         stream.write(ENDCHUNK, 0, ENDCHUNK.length);
         if (wireLog.isDebugEnabled()) {
             wireLog.debug(">> byte(s)" + len + " \\r\\n (chunk length "
@@ -224,7 +229,7 @@
     public void close() throws IOException {
         log.trace("enter ChunkedOutputStream.close()");
 
-        if (!closed) {
+        if (!end) {
             try {
                 // Write the final chunk.
                 stream.write(ZERO, 0, ZERO.length);
@@ -239,10 +244,10 @@
                 // regardless of what happens, mark the stream as closed.
                 // if there are errors closing it, there's not much we can do
                 // about it
-                closed = true;
-                super.close();
+                end = true;
             }
         }
+        super.close();
 
     }
 
@@ -253,4 +258,4 @@
         stream.flush();
     }
 
-}
\ No newline at end of file
+}
Index: src/java/org/apache/commons/httpclient/methods/PostMethod.java
===================================================================
RCS file: 
/home/cvs/mirror/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
retrieving revision 1.27
diff -u -r1.27 PostMethod.java
--- src/java/org/apache/commons/httpclient/methods/PostMethod.java      12 Nov 2002 
09:58:23 -0000      1.27
+++ src/java/org/apache/commons/httpclient/methods/PostMethod.java      21 Nov 2002 
+15:40:45 -0000
@@ -746,6 +746,7 @@
             outstream.write(tmp, 0, i);
             total += i;
         }
+        outstream.write(tmp, 0, 0);
         if ((this.requestContentLength > 0) && (total < this.requestContentLength)) {
             throw new IOException("Unexpected end of input stream after "
                 +total +" bytes (expected "+ this.requestContentLength +" bytes)");

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

Reply via email to