ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | enhydra List | December 2004 Index

<--  Date Index  --> <--  Thread Index  -->

Another patch for com.lutris.mime.MultipartMimeInputStream


Hi there,
     I ran into problems when using an InputStreamReader to read from the MultipartMimeInputStream for a segment of the MIME data (in order to have the reader automatically handle the character encoding) - the InputStreamReader kept reading from the stream for the segment even though it hit the MIME boundary, so the headers of the following parameter would start getting appended to the value.  However, reading from the MultipartMimeInputStream byte-by-byte using the read() method seemed to give the proper results.
    I took a closer look at what was happening, and found that the InputStreamReader was actually calling the read(byte[], int, int) method, as well as the available() method, on the MultipartMimeInputStream object.  The read(byte[], int, int) method seemed to be working OK (calling the readTo() method of a BMByteSearchStream) - it just kept getting called after the MIME boundary was reached.  When I looked at the available() method, I realised it was giving an incorrect result - it was simply calling the BMByteSearchStream's available() method, which gives an indication of how much more data is available from the entire stream, not how much more data is available until the next MIME boundary.  I added an availableTo() method which should provide something close to what's needed, updated the MultipartMimeInputStream's available() method to call availableTo() instead, and this seems to have solved the problem.
 
    The patches (attached) are the addition of the availableTo() method to BMByteSearchStream (applicable to the 'modules/Core/src/com/lutris/util/BMByteSearchStream.java' file in 'enhydra-5.1-16.src.zip') and the update to the available() method in MultipartMimeInputStream (applicable to the 'modules/Core/src/com/lutris/mime/MultipartMimeInputStream.java' file in 'enhydra-5.1-16.src.zip').  If you spot any problems with these changes, or can come up with a better fix, please let me know.
 
Thanks,
Mike.

Attachment: BMByteSearchStream.java.diff
Description: Binary data

Attachment: MultipartMimeInputStream.java.diff
Description: Binary data



<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.