ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/transport/http ChunkedInputStream.java
Date Tue, 15 Mar 2005 17:27:34 GMT
gawor       2005/03/15 09:27:34

  Modified:    java/src/org/apache/axis/transport/http
                        ChunkedInputStream.java
  Log:
  read last \r\n if this is the last token
  
  Revision  Changes    Path
  1.10      +20 -8     ws-axis/java/src/org/apache/axis/transport/http/ChunkedInputStream.java
  
  Index: ChunkedInputStream.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/ChunkedInputStream.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ChunkedInputStream.java	22 Nov 2004 18:11:13 -0000	1.9
  +++ ChunkedInputStream.java	15 Mar 2005 17:27:34 -0000	1.10
  @@ -26,10 +26,15 @@
    */
   
   public class ChunkedInputStream extends java.io.FilterInputStream {
  +
       protected long chunkSize = 0l;
       protected volatile boolean closed = false;
  -    private static final int maxCharLong = (Long.toHexString(Long.MAX_VALUE))
  -      .toString().length();
  +    
  +    private static final int maxCharLong = 
  +        (Long.toHexString(Long.MAX_VALUE)).toString().length();
  +    
  +    private byte[] buf = new byte[maxCharLong + 2];
  +
       private ChunkedInputStream () {
           super(null);
       }
  @@ -127,10 +132,7 @@
       }
                 
       protected long getChunked()throws IOException {
  -        //StringBuffer buf= new StringBuffer(1024);
  -        byte[]buf = new byte[maxCharLong + 2];
           int bufsz = 0;
  - 
           chunkSize = -1L; 
           int c = -1;
   
  @@ -158,13 +160,23 @@
               closed = true;
               throw new IOException("'" + sbuf + "' " + ne.getMessage());
           }
  -        if (chunkSize < 1L) closed = true;                  
  +        if (chunkSize < 0L) {
  +            closed = true;
  +        } if (chunkSize == 0) {
  +            closed = true;
  +            // consume last \r\n tokens of 0\r\n\r\n chunk
  +            if (in.read() != -1) {
  +                in.read();
  +            }
  +        }
           if (chunkSize != 0L && c < 0) {
               //If chunk size is zero try and be tolerant that there maybe no cr or lf at
the end.
               throw new IOException("HTTP Chunked stream closed in middle of chunk.");
           }
  -        if (chunkSize < 0L) throw new IOException("HTTP Chunk size received " +
  -            chunkSize + " is less than zero.");
  +        if (chunkSize < 0L) {
  +            throw new IOException("HTTP Chunk size received " +
  +                                  chunkSize + " is less than zero.");
  +        }
           return chunkSize;                  
       }
   
  
  
  

Mime
View raw message