You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ms...@apache.org on 2001/01/05 22:51:37 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/upload MultipartIterator.java
mschachter 01/01/05 13:51:37
Modified: src/share/org/apache/struts/upload MultipartIterator.java
Log:
Update MultipartIterator to use mark() and reset() methods in containers
that support it. This will enable the ServletInputStream for a multipart
request to be read multiple times
Submitted By: Scott Snyder
Revision Changes Path
1.8 +17 -2 jakarta-struts/src/share/org/apache/struts/upload/MultipartIterator.java
Index: MultipartIterator.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/upload/MultipartIterator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MultipartIterator.java 2000/12/27 23:46:04 1.7
+++ MultipartIterator.java 2001/01/05 21:51:35 1.8
@@ -192,6 +192,16 @@
textData.toString().getBytes("ISO-8859-1"));
return element;
}
+ //reset stream
+ if (inputStream.markSupported()) {
+ try {
+ inputStream.reset();
+ }
+ catch (IOException ioe) {
+ throw new ServletException("IOException while resetting input stream: " +
+ ioe.getMessage());
+ }
+ }
return null;
}
@@ -234,7 +244,7 @@
* Handles retrieving the boundary and setting the input stream
*/
protected void parseRequest() throws ServletException {
-
+
contentLength = request.getContentLength();
//set boundary
@@ -243,13 +253,18 @@
try {
//set the input stream
inputStream = request.getInputStream();
+ //mark the input stream to allow multiple reads
+ if (inputStream.markSupported()) {
+ inputStream.mark(contentLength+1);
+ }
+
}
catch (IOException ioe) {
throw new ServletException("MultipartIterator.parseRequest(): " +
"IOException while trying to obtain " +
"ServletInputStream");
}
-
+
if ((boundary == null) || (boundary.length() < 1)) {
//try retrieving the header through more "normal" means
boundary = parseBoundary(request.getHeader("Content-type"));