hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r752031 - /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
Date Tue, 10 Mar 2009 10:01:40 GMT
Author: olegk
Date: Tue Mar 10 10:01:40 2009
New Revision: 752031

URL: http://svn.apache.org/viewvc?rev=752031&view=rev
Log:
Code cleanups

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java?rev=752031&r1=752030&r2=752031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
Tue Mar 10 10:01:40 2009
@@ -63,6 +63,8 @@
     private static final int CHUNK_DATA              = 2;
     private static final int CHUNK_CRLF              = 3;
     
+    private static final int BUFFER_SIZE = 2048;
+    
     /** The session input buffer */
     private final SessionInputBuffer in;
 
@@ -244,7 +246,7 @@
                 throw new MalformedChunkCodingException("Bad chunk header");
             }
         default:
-            throw new IllegalStateException("Incontent state");
+            throw new IllegalStateException("Inconsistent codec state");
         }
     }
 
@@ -274,7 +276,10 @@
         if (!closed) {
             try {
                 if (!eof) {
-                    exhaustInputStream(this);
+                    // read and discard the remainder of the message
+                    byte buffer[] = new byte[BUFFER_SIZE];
+                    while (read(buffer) >= 0) {
+                    }
                 }
             } finally {
                 eof = true;
@@ -286,13 +291,5 @@
     public Header[] getFooters() {
         return (Header[])this.footers.clone();
     }
-    
-    static void exhaustInputStream(final InputStream inStream) throws IOException {
-        // read and discard the remainder of the message
-        byte buffer[] = new byte[1024];
-        while (inStream.read(buffer) >= 0) {
-            // discard data
-        }
-    }
 
 }



Mime
View raw message