commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mart...@apache.org
Subject cvs commit: jakarta-commons/fileupload/src/java/org/apache/commons/fileupload DiskFileUpload.java FileUpload.java FileUploadBase.java MultipartStream.java
Date Sun, 01 Jun 2003 00:18:13 GMT
martinc     2003/05/31 17:18:13

  Modified:    fileupload/src/java/org/apache/commons/fileupload
                        DiskFileUpload.java FileUpload.java
                        FileUploadBase.java MultipartStream.java
  Log:
  Add the ability to specify the content encoding used for part headers. This
  shouldn't really be necessary, but browsers don't comply with the spec on
  this issue, and this provides a way for clients to work around that.
  
  Fixes Bugzilla #14120, reported by Joachim Gjesdal. The fix is based on
  patches supplied by Shinsuke SUGAYA and Haihan Ji.
  
  Revision  Changes    Path
  1.3       +6 -6      jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DiskFileUpload.java
  
  Index: DiskFileUpload.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DiskFileUpload.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DiskFileUpload.java	31 May 2003 22:31:08 -0000	1.2
  +++ DiskFileUpload.java	1 Jun 2003 00:18:13 -0000	1.3
  @@ -78,8 +78,8 @@
    * org.apache.commons.fileupload.FileItem}s associated with a given HTML
    * widget.</p>
    *
  - * <p> Files will be stored in temporary disk storage or in memory,
  - * depending on request size, and will be available as {@link
  + * <p>Individual parts will be stored in temporary disk storage or in memory,
  + * depending on their size, and will be available as {@link
    * org.apache.commons.fileupload.FileItem}s.</p>
    *
    * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
  
  
  
  1.21      +7 -7      jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java
  
  Index: FileUpload.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- FileUpload.java	31 May 2003 22:31:08 -0000	1.20
  +++ FileUpload.java	1 Jun 2003 00:18:13 -0000	1.21
  @@ -78,9 +78,9 @@
    * org.apache.commons.fileupload.FileItem}s associated with a given HTML
    * widget.</p>
    *
  - * <p> Files will be stored in temporary disk storage or in memory,
  - * depending on request size, and will be available as {@link
  - * org.apache.commons.fileupload.FileItem}s.</p>
  + * <p>How the data for individual parts is stored is determined by the factory
  + * used to create them; a given part may be in memory, on disk, or somewhere
  + * else.</p>
    *
    * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
  
  
  
  1.3       +41 -7     jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUploadBase.java
  
  Index: FileUploadBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUploadBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileUploadBase.java	31 May 2003 22:31:08 -0000	1.2
  +++ FileUploadBase.java	1 Jun 2003 00:18:13 -0000	1.3
  @@ -83,9 +83,9 @@
    * org.apache.commons.fileupload.FileItem}s associated with a given HTML
    * widget.</p>
    *
  - * <p> Files will be stored in temporary disk storage or in memory,
  - * depending on request size, and will be available as {@link
  - * org.apache.commons.fileupload.FileItem}s.</p>
  + * <p>How the data for individual parts is stored is determined by the factory
  + * used to create them; a given part may be in memory, on disk, or somewhere
  + * else.</p>
    *
    * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
  @@ -188,6 +188,12 @@
       private long sizeMax = -1;
   
   
  +    /**
  +     * The content encoding to use when reading part headers.
  +     */
  +    private String headerEncoding;
  +
  +
       // ----------------------------------------------------- Property accessors
   
   
  @@ -235,6 +241,32 @@
       }
   
   
  +    /**
  +     * Retrieves the character encoding used when reading the headers of an
  +     * individual part. When not specified, or <code>null</code>, the platform
  +     * default encoding is used.
  +     *
  +     * @return The encoding used to read part headers.
  +     */
  +    public String getHeaderEncoding()
  +    {
  +        return headerEncoding;
  +    }
  +
  +
  +    /**
  +     * Specifies the character encoding to be used when reading the headers of
  +     * individual parts. When not specified, or <code>null</code>, the platform
  +     * default encoding is used.
  +     *
  +     * @param encoding The encoding used to read part headers.
  +     */
  +    public void setHeaderEncoding(String encoding)
  +    {
  +        headerEncoding = encoding;
  +    }
  +
  +
       // --------------------------------------------------------- Public methods
   
   
  @@ -302,6 +334,8 @@
               InputStream input = req.getInputStream();
   
               MultipartStream multi = new MultipartStream(input, boundary);
  +            multi.setHeaderEncoding(headerEncoding);
  +
               boolean nextPart = multi.skipPreamble();
               while (nextPart)
               {
  
  
  
  1.12      +59 -5     jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/MultipartStream.java
  
  Index: MultipartStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/MultipartStream.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MultipartStream.java	27 Apr 2003 17:30:06 -0000	1.11
  +++ MultipartStream.java	1 Jun 2003 00:18:13 -0000	1.12
  @@ -67,6 +67,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  +import java.io.UnsupportedEncodingException;
   
   
   /**
  @@ -226,6 +227,12 @@
       private int tail;
   
   
  +    /**
  +     * The content encoding to use when reading headers.
  +     */
  +    private String headerEncoding;
  +
  +
       // ----------------------------------------------------------- Constructors
   
   
  @@ -308,6 +315,33 @@
   
   
       /**
  +     * Retrieves the character encoding used when reading the headers of an
  +     * individual part. When not specified, or <code>null</code>, the platform
  +     * default encoding is used.
  +
  +     *
  +     * @return The encoding used to read part headers.
  +     */
  +    public String getHeaderEncoding()
  +    {
  +        return headerEncoding;
  +    }
  +
  +
  +    /**
  +     * Specifies the character encoding to be used when reading the headers of
  +     * individual parts. When not specified, or <code>null</code>, the platform
  +     * default encoding is used.
  +     *
  +     * @param encoding The encoding used to read part headers.
  +     */
  +    public void setHeaderEncoding(String encoding)
  +    {
  +        headerEncoding = encoding;
  +    }
  +
  +
  +    /**
        * Reads a byte from the <code>buffer</code>, and refills it as
        * necessary.
        *
  @@ -456,7 +490,27 @@
                   baos.write(b[0]);
               }
           }
  -        return baos.toString();
  +
  +        String headers = null;
  +        if (headerEncoding != null)
  +        {
  +            try
  +            {
  +                headers = baos.toString(headerEncoding);
  +            }
  +            catch (UnsupportedEncodingException e)
  +            {
  +                // Fall back to platform default if specified encoding is not
  +                // supported.
  +                headers = baos.toString();
  +            }
  +        }
  +        else
  +        {
  +            headers = baos.toString();
  +        }
  +
  +        return headers;
       }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message