tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/web new.html
Date Thu, 20 Feb 2003 16:33:39 GMT
hlship      2003/02/20 08:33:39

  Modified:    framework/src/net/sf/tapestry/multipart LineInput.java
                        UploadOutputStream.java
                        DefaultMultipartDecoder.java
               web      new.html
  Log:
  [ 679655 ] Upload component very slow on file uploads
  
  Revision  Changes    Path
  1.9       +14 -7     jakarta-tapestry/framework/src/net/sf/tapestry/multipart/LineInput.java
  
  Index: LineInput.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/net/sf/tapestry/multipart/LineInput.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LineInput.java	19 Feb 2003 23:22:13 -0000	1.8
  +++ LineInput.java	20 Feb 2003 16:33:39 -0000	1.9
  @@ -54,11 +54,9 @@
    */
   package net.sf.tapestry.multipart;
   
  -import java.io.FileOutputStream;
  -import java.io.FilterInputStream;
  +import java.io.BufferedInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.io.OutputStream;
   
   /**
    *  Allows an input stream to be read as both individual lines
  @@ -73,7 +71,7 @@
    *
    **/
   
  -public class LineInput extends FilterInputStream
  +public class LineInput extends BufferedInputStream
   {
       public static final int EOF = -1;
       public static final int CR = 13;
  @@ -119,7 +117,7 @@
   
       public String readLine() throws IOException
       {
  -        ByteBuffer buffer = new ByteBuffer();
  +        ByteBuffer buffer = null;
   
           while (true)
           {
  @@ -131,15 +129,24 @@
               if (b == CR)
               {
                   // Skip the LF that follows
  -                read();
  +                mark(1);
  +                if (read() != LF)
  +                    reset();
  +
                   break;
               }
   
               if (b == LF)
                   break;
  +                
  +            if (buffer == null)
  +                buffer = new ByteBuffer();
   
               buffer.add((byte) b);
           }
  +
  +        if (buffer == null)
  +            return null;
   
           return buffer.getString();
       }
  
  
  
  1.9       +5 -4      jakarta-tapestry/framework/src/net/sf/tapestry/multipart/UploadOutputStream.java
  
  Index: UploadOutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/net/sf/tapestry/multipart/UploadOutputStream.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- UploadOutputStream.java	13 Jan 2003 03:33:23 -0000	1.8
  +++ UploadOutputStream.java	20 Feb 2003 16:33:39 -0000	1.9
  @@ -54,6 +54,7 @@
    */
   package net.sf.tapestry.multipart;
   
  +import java.io.BufferedOutputStream;
   import java.io.ByteArrayOutputStream;
   import java.io.File;
   import java.io.FileOutputStream;
  @@ -83,7 +84,7 @@
       private OutputStream _activeStream = _byteArrayStream;
       private int _limit;
       private int _count = 0;
  -    private FileOutputStream _fileStream;
  +    private OutputStream _fileStream;
       private File _file;
   
       UploadOutputStream()
  @@ -103,7 +104,7 @@
   
       public void flush() throws IOException
       {
  -        _activeStream.close();
  +        _activeStream.flush();
       }
   
       public void write(byte[] b, int off, int len) throws IOException
  @@ -140,7 +141,7 @@
   
           _file = File.createTempFile("upload-", ".bin");
   
  -        _fileStream = new FileOutputStream(_file);
  +        _fileStream = new BufferedOutputStream(new FileOutputStream(_file));
   
           _byteArrayStream.close();
   
  
  
  
  1.3       +27 -14    jakarta-tapestry/framework/src/net/sf/tapestry/multipart/DefaultMultipartDecoder.java
  
  Index: DefaultMultipartDecoder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/net/sf/tapestry/multipart/DefaultMultipartDecoder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultMultipartDecoder.java	19 Feb 2003 23:22:13 -0000	1.2
  +++ DefaultMultipartDecoder.java	20 Feb 2003 16:33:39 -0000	1.3
  @@ -65,13 +65,12 @@
   
   import javax.servlet.http.HttpServletRequest;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -
   import net.sf.tapestry.ApplicationRuntimeException;
   import net.sf.tapestry.IUploadFile;
   import net.sf.tapestry.Tapestry;
   import net.sf.tapestry.util.StringSplitter;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    *  Decodes the data in a <code>multipart/form-data</code> HTTP request, handling
  @@ -133,7 +132,9 @@
       {
           if (!isMultipartRequest(request))
               throw new ApplicationRuntimeException(
  -                Tapestry.getString("MultipartDecoder.wrong-content-type", request.getContentType()));
  +                Tapestry.getString(
  +                    "MultipartDecoder.wrong-content-type",
  +                    request.getContentType()));
   
           String contentType = request.getContentType();
           int pos = contentType.indexOf(BOUNDARY);
  @@ -158,7 +159,9 @@
           }
           catch (IOException ex)
           {
  -            LOG.error(Tapestry.getString("MultipartDecoder.io-exception-reading-input",
ex.getMessage()), ex);
  +            LOG.error(
  +                Tapestry.getString("MultipartDecoder.io-exception-reading-input", ex.getMessage()),
  +                ex);
   
               // Cleanup any partial upload files.
   
  @@ -177,10 +180,11 @@
       {
           String line = input.readLine();
   
  -        if (line.equals(boundary))
  +        if (line != null && line.equals(boundary))
               return;
   
  -        throw new ApplicationRuntimeException(Tapestry.getString("MultipartDecoder.missing-initial-boundary"));
  +        throw new ApplicationRuntimeException(
  +            Tapestry.getString("MultipartDecoder.missing-initial-boundary"));
       }
   
       private boolean readNextPart(LineInput input, byte[] boundary) throws IOException
  @@ -194,7 +198,7 @@
           {
               String line = input.readLine();
   
  -            if (line.length() == 0)
  +            if (line == null || line.length() == 0)
                   break;
   
               int colonx = line.indexOf(':');
  @@ -219,7 +223,8 @@
           }
   
           if (disposition == null)
  -            throw new ApplicationRuntimeException(Tapestry.getString("MultipartDecoder.missing-content-disposition"));
  +            throw new ApplicationRuntimeException(
  +                Tapestry.getString("MultipartDecoder.missing-content-disposition"));
   
           Map dispositionMap = explodeDisposition(disposition);
           String name = (String) dispositionMap.get("name");
  @@ -257,7 +262,9 @@
   
               if (!(rawValue.startsWith(QUOTE) && rawValue.endsWith(QUOTE)))
                   throw new ApplicationRuntimeException(
  -                    Tapestry.getString("MultipartDecoder.invalid-content-disposition",
disposition));
  +                    Tapestry.getString(
  +                        "MultipartDecoder.invalid-content-disposition",
  +                        disposition));
   
               result.put(key, rawValue.substring(1, rawValue.length() - 1));
   
  @@ -266,14 +273,19 @@
           return result;
       }
   
  -    private boolean readFilePart(LineInput input, byte[] boundary, String name, String
fileName, String contentType)
  +    private boolean readFilePart(
  +        LineInput input,
  +        byte[] boundary,
  +        String name,
  +        String fileName,
  +        String contentType)
           throws IOException
       {
           UploadOutputStream uploadStream = new UploadOutputStream();
   
           boolean last = readIntoStream(input, boundary, uploadStream);
   
  -		uploadStream.close();
  +        uploadStream.close();
   
           File file = uploadStream.getContentFile();
   
  @@ -331,7 +343,8 @@
        * 
        **/
   
  -    private boolean readIntoStream(LineInput input, byte[] boundary, OutputStream stream)
throws IOException
  +    private boolean readIntoStream(LineInput input, byte[] boundary, OutputStream stream)
  +        throws IOException
       {
           boolean result = false;
           int c = 0;
  
  
  
  1.125     +3 -1      jakarta-tapestry/web/new.html
  
  Index: new.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/web/new.html,v
  retrieving revision 1.124
  retrieving revision 1.125
  diff -u -r1.124 -r1.125
  --- new.html	7 Feb 2003 04:30:00 -0000	1.124
  +++ new.html	20 Feb 2003 16:33:39 -0000	1.125
  @@ -36,6 +36,8 @@
   <pre>
   [ 665622 ] net.sf.tapestry.html.Frame uses old DOCTYPE
   [ 675882 ] option component generates invalid HTML
  +[ 622691 ] Full release
  +[ 679655 ] Upload component very slow on file uploads
   </pre>		
   		
   <h3>Release 2.4-alpha-2</h3>
  
  
  

Mime
View raw message