You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2002/11/10 07:31:11 UTC
cvs commit: jakarta-commons/fileupload/src/java/org/apache/commons/fileupload FileUpload.java
martinc 2002/11/09 22:31:11
Modified: fileupload/src/java/org/apache/commons/fileupload
FileUpload.java
Log:
Add isMultipartContent() method, per patch supplied by Robert Burrell
Donkin, modified to satisfy coding guidelines. Thanks, Robert!
Fix miscellaneous other coding guidelines violations.
Revision Changes Path
1.14 +36 -11 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FileUpload.java 27 Oct 2002 17:11:46 -0000 1.13
+++ FileUpload.java 10 Nov 2002 06:31:10 -0000 1.14
@@ -101,6 +101,32 @@
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.
+ *
+ * @return <code>true</code> if the request is multipart;
+ * <code>false</code> otherwise.
+ */
+ public static final boolean isMultipartContent(HttpServletRequest req)
+ {
+ String contentType = req.getHeader(CONTENT_TYPE);
+ if (contentType == null)
+ {
+ return false;
+ }
+ if (contentType.startsWith(MULTIPART))
+ {
+ return true;
+ }
+ return false;
+ }
+
+
// ----------------------------------------------------- Manifest constants
@@ -310,7 +336,6 @@
// --------------------------------------------------------- Public methods
-
/**
* Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
* compliant <code>multipart/form-data</code> stream. If files are stored
@@ -353,15 +378,15 @@
int sizeMax, String path)
throws FileUploadException
{
- if (null == req)
- {
- throw new NullPointerException("req parameter");
- }
-
+ if (null == req)
+ {
+ throw new NullPointerException("req parameter");
+ }
+
ArrayList items = new ArrayList();
String contentType = req.getHeader(CONTENT_TYPE);
- if ( (null == contentType) || (!contentType.startsWith(MULTIPART)) )
+ if ((null == contentType) || (!contentType.startsWith(MULTIPART)))
{
throw new FileUploadException("the request doesn't contain a "
+ MULTIPART_FORM_DATA
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>