You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jose de Castro <jo...@voxeo.com> on 2008/03/05 01:19:50 UTC

ExtensionsFilter - Disable Multipart Wrapping

Hello,

I've been a MyFaces/Tomawahk user for the last few years. For the  
longest time, it completely served my needs and was very happy with  
the level of support that I received from the community. About a year  
ago, I decided to adopt JBoss Seam and a way to augment my own  
implementation of "conversations" in JSF. All was well until I  
decided to use Seam's fielUpload component alongside the MyFaces  
ExtensionFilter. (see: http://www.jboss.com/index.html? 
module=bb&op=viewtopic&p=4013611#4013611)

The ExtensionFilter is great at many things but lacks modularity in  
my opinion. I shouldn't be forced to MultipartRequestWrapper in order  
to get resource streaming and content negotiation. I've attached a  
patch that allows a user to disable "Multipart Request Wrapping" via  
an init parameter while leaving the default behavior intact. I've  
been running this patch in QA for a few days and all seems well.

Does this seem like something that could eventually make it in the  
next release? If not, what would be a suitable alternative?

Please excuse me if I'm breaking protocol by in-lining a diff but I  
wasn't sure how you guys operate for these kind of things.

Thanks in advance,

Jose de castro
Sr. Software Engineer
Voxeo Corporation


Index: /Users/jdecastro/Work/Libraries/tomahawk-1.1.6-src/core/src/ 
main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
===================================================================
--- /Users/jdecastro/Work/Libraries/tomahawk-1.1.6-src/core/src/main/ 
java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java	(revision  
633249)
+++ /Users/jdecastro/Work/Libraries/tomahawk-1.1.6-src/core/src/main/ 
java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java	(working  
copy)
@@ -47,6 +47,8 @@

      private String _uploadRepositoryPath = null; //standard temp  
directory

+    private boolean _enableMultipartWrapper = true;
+
      private ServletContext _servletContext;

      public static final String DOFILTER_CALLED =  
"org.apache.myfaces.component.html.util.ExtensionFilter.doFilterCalled";
@@ -66,6 +68,11 @@

          _uploadRepositoryPath = filterConfig.getInitParameter 
("uploadRepositoryPath");

+        String enabledWrapperValue = filterConfig.getInitParameter 
("enableMultipartWrapper");
+        if(enabledWrapperValue != null) {
+            _enableMultipartWrapper = Boolean.parseBoolean 
(enabledWrapperValue);
+        }
+
          _servletContext = filterConfig.getServletContext();
      }

@@ -114,7 +121,7 @@
          HttpServletRequest extendedRequest = httpRequest;

          // For multipart/form-data requests
-        if (FileUpload.isMultipartContent(httpRequest)) {
+        if (_enableMultipartWrapper && FileUpload.isMultipartContent 
(httpRequest)) {
              extendedRequest = new MultipartRequestWrapper 
(httpRequest, _uploadMaxFileSize, _uploadThresholdSize,  
_uploadRepositoryPath);
          }