commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samuel Cheung <SChe...@Novarra.com>
Subject [ FileUpload] Question regarding MultipartStream class in FileUpl oad library
Date Wed, 31 Mar 2004 15:06:36 GMT
 I try to use the MultipartStream class in the FileUpdate to parse the 
 HTTP request in Multipart.

 I think I found a bug if the Content length in the part is 0, it will 
 mess up the rest of the data and header.



 Here is an example:

 "--=====ABC 123456789=====\r\n" +

     "Content-Type: text/plain\r\n" +

     "Subject: Test message \r\n" +

     "Content-Length: 0 \r\n" +

     "\r\n" +

     "--=====ABC 123456789=====\r\n" +

     "Content-Type: text/plain;\r\n" +

     "Content-Length: 11 \r\n" +

     "\r\n" +

     "Hello World\r\n" +

     "\r\n" +

     "--===== ABC 123456789=====--\r\n";

 I am using the sample code to get the header and data.

   boolean nextPart = malitPartStream.skipPreamble();

   ByteArrayOutputStream output = new ByteArrayOutputStream();

                 while(nextPart) {

                     System.out.println("Found part!");

                   String header = malitPartStream.readHeaders();

                   System.out.println ("<<<<header>>>>" + header 
 +"<<<<<<<");



                     // create some output stream

                     malitPartStream.readBodyData(output);



                     System.out.println("<<<<data>>>>" + new 
 String(output.toByteArray()));



                   nextPart = malitPartStream.readBoundary();

                 }



 I try skipping the call to readBodyData() if the content length in the 
 header is zero, but I got a MalformedStreamException instead.



 I appreciate if you agree if this is a bug and if there is a work 
 around for it.



 Thank you.





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message