fileupload works with multipart content - and only multipart content. this patch adds a utility method that determines (in the same way as fileupload does) whether a request contains multipart content.

- robert

Index: src/java/org/apache/commons/fileupload/FileUpload.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java,v
retrieving revision 1.13
diff -u -r1.13 FileUpload.java
--- src/java/org/apache/commons/fileupload/FileUpload.java      27 Oct 2002 17:11:46 
-0000      1.13
+++ src/java/org/apache/commons/fileupload/FileUpload.java      5 Nov 2002 19:12:29 
+-0000
@@ -101,6 +101,28 @@
 public class FileUpload
 {
 
+    // ----------------------------------------------------- Class methods
+    
+    /**
+     * Utility method that determines whether the request contains multipart content.
+     *
+     * @param req           The servlet request to be evaluated. Must be non-null.
+     */
+    public final static boolean isMultipartContent(HttpServletRequest req) 
+    {
+        String contentType = req.getHeader(CONTENT_TYPE);
+        if ( null == contentType ) 
+        {
+            return false;
+        }
+        if ( contentType.startsWith(MULTIPART) ) 
+        {
+            return true;
+        }
+        return false;
+    }
+    
+
     // ----------------------------------------------------- Manifest constants
 
 
@@ -309,7 +331,6 @@
 
 
     // --------------------------------------------------------- Public methods
-
 
     /**
      * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt";>RFC 1867</a>

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

Reply via email to