[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpcomponents-commits
Subject:    svn commit: r374920 - in /jakarta/httpcomponents/trunk/http-core/src:
From:       olegk () apache ! org
Date:       2006-02-04 20:28:42
Message-ID: 20060204202844.71722.qmail () minotaur ! apache ! org
[Download RAW message or body]

Author: olegk
Date: Sat Feb  4 12:28:25 2006
New Revision: 374920

URL: http://svn.apache.org/viewcvs?rev=374920&view=rev
Log:
Changelog:
- HttpEntity#writeTo no longer returns a boolean value
- HttpEntity#writeTo is required to stream out the complete entity's content

Modified:
    jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/compress/GzipCompressingEntity.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/HttpEntityWrapper.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntityWriter.java
  jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntityWriter.java
  jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java


Modified: jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/compress/GzipCompressingEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/contrib/ \
org/apache/http/contrib/compress/GzipCompressingEntity.java?rev=374920&r1=374919&r2=374920&view=diff
 ==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/compress/GzipCompressingEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/compress/GzipCompressingEntity.java \
Sat Feb  4 12:28:25 2006 @@ -69,7 +69,7 @@
         return true;
     }
 
-    public boolean writeTo(final OutputStream outstream) throws IOException {
+    public void writeTo(final OutputStream outstream) throws IOException {
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
@@ -81,8 +81,6 @@
             gzip.write(tmp, 0, l);
         }
         gzip.close();
-        outstream.close();
-        return true;
     }
 
 } // class GzipCompressingEntity

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java?rev=374920&r1=374919&r2=374920&view=diff
 ==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java \
Sat Feb  4 12:28:25 2006 @@ -136,21 +136,13 @@
     InputStream getContent() throws IOException;
 
     /**
-     * Writes the entity content to the output stream either partially or entirely.
-     * This method may either write the entire content in one go, if it is feasible 
-     * to do so, or store the output stream as a local variable and use it \
                internally 
-     * to write the content in parts. In the former case this method MUST return
-     * <tt>true</tt> to indicate that the output stream can be closed. In the latter
-     * case the output stream MUST be closed once the last content part is written
-     * in order to ensure that content codings that emit a closing chunk are \
                properly
-     * terminated.  
+     * Writes the entity content to the output stream.  
      * 
      * @param outstream the output stream to write entity content to
-     * @return <tt>true</tt> if the entire entity content has been written, 
-     *   <tt>false</tt> otherwise.
+     * 
      * @throws IOException if an I/O error occurs
      */
-    boolean writeTo(OutputStream outstream) throws IOException;
+    void writeTo(OutputStream outstream) throws IOException;
 
     /**
      * Tells whether this entity depends on an underlying stream.

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org \
/apache/http/entity/BasicHttpEntity.java?rev=374920&r1=374919&r2=374920&view=diff \
                ==============================================================================
                
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java \
Sat Feb  4 12:28:25 2006 @@ -101,12 +101,12 @@
         this.content = instream; 
     }
     
-    public boolean writeTo(final OutputStream outstream) throws IOException {
+    public void writeTo(final OutputStream outstream) throws IOException {
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
         if (this.content == null) {
-            return true;
+            return;
         }
         InputStream instream = this.content;
         int l;
@@ -114,7 +114,6 @@
         while ((l = instream.read(tmp)) != -1) {
             outstream.write(tmp, 0, l);
         }
-        return true;
     }
 
 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org \
/apache/http/entity/BufferedHttpEntity.java?rev=374920&r1=374919&r2=374920&view=diff \
                ==============================================================================
                
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java \
Sat Feb  4 12:28:25 2006 @@ -98,15 +98,14 @@
     }
 
     
-    public boolean writeTo(final OutputStream outstream) throws IOException {
+    public void writeTo(final OutputStream outstream) throws IOException {
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
         if (this.buffer != null) {
             outstream.write(this.buffer);
-            return true;
         } else {
-            return wrappedEntity.writeTo(outstream);
+            wrappedEntity.writeTo(outstream);
         }
     }
 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org \
/apache/http/entity/ByteArrayEntity.java?rev=374920&r1=374919&r2=374920&view=diff \
                ==============================================================================
                
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java \
Sat Feb  4 12:28:25 2006 @@ -67,13 +67,12 @@
         return new ByteArrayInputStream(this.content);
     }
     
-    public boolean writeTo(final OutputStream outstream) throws IOException {
+    public void writeTo(final OutputStream outstream) throws IOException {
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
         outstream.write(this.content);
         outstream.flush();
-        return true;
     }
 
 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java?rev=374920&r1=374919&r2=374920&view=diff
 ==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java \
Sat Feb  4 12:28:25 2006 @@ -68,7 +68,7 @@
         return new FileInputStream(this.file);
     }
     
-    public boolean writeTo(final OutputStream outstream) throws IOException {
+    public void writeTo(final OutputStream outstream) throws IOException {
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
@@ -79,7 +79,6 @@
             outstream.write(tmp, 0, l);
         }
         outstream.flush();
-        return true;
     }
 
     /**

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/HttpEntityWrapper.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org \
/apache/http/entity/HttpEntityWrapper.java?rev=374920&r1=374919&r2=374920&view=diff \
                ==============================================================================
                
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/HttpEntityWrapper.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/HttpEntityWrapper.java \
Sat Feb  4 12:28:25 2006 @@ -94,9 +94,9 @@
         return wrappedEntity.getContent();
     }
 
-    public boolean writeTo(OutputStream outstream)
+    public void writeTo(OutputStream outstream)
         throws IOException {
-        return wrappedEntity.writeTo(outstream);
+        wrappedEntity.writeTo(outstream);
     }
 
     public boolean isStreaming() {

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org \
/apache/http/entity/InputStreamEntity.java?rev=374920&r1=374919&r2=374920&view=diff \
                ==============================================================================
                
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java \
Sat Feb  4 12:28:25 2006 @@ -70,7 +70,7 @@
         return this.content;
     }
         
-    public boolean writeTo(final OutputStream outstream) throws IOException {
+    public void writeTo(final OutputStream outstream) throws IOException {
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
@@ -85,7 +85,6 @@
             outstream.write(buffer, 0, l);
     	    remaining -= l;
     	}
-        return true;
     }
 
     // non-javadoc, see interface HttpEntity

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java?rev=374920&r1=374919&r2=374920&view=diff
 ==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java \
Sat Feb  4 12:28:25 2006 @@ -80,13 +80,12 @@
         return new ByteArrayInputStream(this.content);
     }
     
-    public boolean writeTo(final OutputStream outstream) throws IOException {
+    public void writeTo(final OutputStream outstream) throws IOException {
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
         outstream.write(this.content);
         outstream.flush();
-        return true;
     }
 
     /**

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntityWriter.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org \
/apache/http/impl/entity/DefaultClientEntityWriter.java?rev=374920&r1=374919&r2=374920&view=diff
 ==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntityWriter.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntityWriter.java \
Sat Feb  4 12:28:25 2006 @@ -82,9 +82,8 @@
         } else {
             outstream = new ContentLengthOutputStream(datatransmitter, len);
         }
-        if (entity.writeTo(outstream)) {
-            outstream.close();
-        }
+        entity.writeTo(outstream);
+        outstream.close();
     }
     
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntityWriter.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org \
/apache/http/impl/entity/DefaultServerEntityWriter.java?rev=374920&r1=374919&r2=374920&view=diff
 ==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntityWriter.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntityWriter.java \
Sat Feb  4 12:28:25 2006 @@ -79,9 +79,8 @@
         } else {
             outstream = new IdentityOutputStream(datatransmitter); 
         }
-        if (entity.writeTo(outstream)) {
-            outstream.close();
-        }
+        entity.writeTo(outstream);
+        outstream.close();
     }
     
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/test/org \
/apache/http/entity/TestHttpEntities.java?rev=374920&r1=374919&r2=374920&view=diff \
                ==============================================================================
                
--- jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java \
                (original)
+++ jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java \
Sat Feb  4 12:28:25 2006 @@ -88,7 +88,7 @@
     	httpentity.setContent(content);
     	
     	ByteArrayOutputStream out = new ByteArrayOutputStream();
-    	assertTrue(httpentity.writeTo(out));
+    	httpentity.writeTo(out);
     	byte[] bytes2 = out.toByteArray();
     	assertNotNull(bytes2);
     	assertEquals(bytes.length, bytes2.length);
@@ -97,14 +97,14 @@
     	}
 
     	out = new ByteArrayOutputStream();
-    	assertTrue(httpentity.writeTo(out));
+    	httpentity.writeTo(out);
     	bytes2 = out.toByteArray();
     	assertNotNull(bytes2);
     	assertEquals(0, bytes2.length);
     	
     	httpentity.setContent(null);
     	out = new ByteArrayOutputStream();
-    	assertTrue(httpentity.writeTo(out));
+    	httpentity.writeTo(out);
     	bytes2 = out.toByteArray();
     	assertNotNull(bytes2);
     	assertEquals(0, bytes2.length);
@@ -148,7 +148,7 @@
     	ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
     	
     	ByteArrayOutputStream out = new ByteArrayOutputStream();
-    	assertTrue(httpentity.writeTo(out));
+    	httpentity.writeTo(out);
     	byte[] bytes2 = out.toByteArray();
     	assertNotNull(bytes2);
     	assertEquals(bytes.length, bytes2.length);
@@ -157,7 +157,7 @@
     	}
 
     	out = new ByteArrayOutputStream();
-    	assertTrue(httpentity.writeTo(out));
+    	httpentity.writeTo(out);
     	bytes2 = out.toByteArray();
     	assertNotNull(bytes2);
     	assertEquals(bytes.length, bytes2.length);
@@ -216,7 +216,7 @@
         StringEntity httpentity = new StringEntity(s);
         
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        assertTrue(httpentity.writeTo(out));
+        httpentity.writeTo(out);
         byte[] bytes2 = out.toByteArray();
         assertNotNull(bytes2);
         assertEquals(bytes.length, bytes2.length);
@@ -225,7 +225,7 @@
         }
 
         out = new ByteArrayOutputStream();
-        assertTrue(httpentity.writeTo(out));
+        httpentity.writeTo(out);
         bytes2 = out.toByteArray();
         assertNotNull(bytes2);
         assertEquals(bytes.length, bytes2.length);
@@ -275,7 +275,7 @@
         InputStreamEntity httpentity = new InputStreamEntity(instream, 7);
         
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        assertTrue(httpentity.writeTo(out));
+        httpentity.writeTo(out);
         byte[] bytes2 = out.toByteArray();
         assertNotNull(bytes2);
         assertEquals(7, bytes2.length);
@@ -285,7 +285,7 @@
         instream = new ByteArrayInputStream(bytes);
         httpentity = new InputStreamEntity(instream, 20);
         out = new ByteArrayOutputStream();
-        assertTrue(httpentity.writeTo(out));
+        httpentity.writeTo(out);
         bytes2 = out.toByteArray();
         assertNotNull(bytes2);
         assertEquals(bytes.length, bytes2.length);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic