You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/08/01 14:00:57 UTC

git commit: WW-4345 Adds special treatment of parameters during file upload

Repository: struts
Updated Branches:
  refs/heads/develop 1dd873078 -> 8aa4fe860


WW-4345 Adds special treatment of parameters during file upload


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8aa4fe86
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8aa4fe86
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8aa4fe86

Branch: refs/heads/develop
Commit: 8aa4fe860693d29e5ef94026bf2a7532ed74b9ea
Parents: 1dd8730
Author: Lukasz Lenart <lu...@apache.org>
Authored: Fri Aug 1 14:00:46 2014 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Fri Aug 1 14:00:46 2014 +0200

----------------------------------------------------------------------
 .../apache/struts2/dispatcher/Dispatcher.java   | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/8aa4fe86/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 2cdf260..95dc308 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -79,6 +79,8 @@ public class Dispatcher {
      */
     private static final Logger LOG = LoggerFactory.getLogger(Dispatcher.class);
 
+    public static final String MULTIPART_FORM_DATA = "multipart/form-data";
+
     /**
      * Provide a thread local instance.
      */
@@ -625,7 +627,7 @@ public class Dispatcher {
         Map requestMap = new RequestMap(request);
 
         // parameters map wrapping the http parameters.  ActionMapping parameters are now handled and applied separately
-        Map params = new HashMap(request.getParameterMap());
+        Map params = prepareParametersMap(request);
 
         // session map wrapping the http session
         Map session = new SessionMap(request);
@@ -642,6 +644,21 @@ public class Dispatcher {
     }
 
     /**
+     * Copies or creates new map to hold request parameters,
+     * there is a special treatment when uploading a file see WW-4345
+     */
+    protected Map prepareParametersMap(HttpServletRequest request) {
+        Map params;
+        String contentType = request.getContentType();
+        if (contentType != null && contentType.contains(MULTIPART_FORM_DATA)) {
+			params = new HashMap();
+		} else {
+			params = new HashMap(request.getParameterMap());
+		}
+        return params;
+    }
+
+    /**
      * @deprecated use version without ServletContext param
      */
     @Deprecated
@@ -829,7 +846,7 @@ public class Dispatcher {
         }
 
         String content_type = request.getContentType();
-        if (content_type != null && content_type.contains("multipart/form-data")) {
+        if (content_type != null && content_type.contains(MULTIPART_FORM_DATA)) {
             MultiPartRequest mpr = getMultiPartRequest();
             LocaleProvider provider = getContainer().getInstance(LocaleProvider.class);
             request = new MultiPartRequestWrapper(mpr, request, getSaveDir(), provider);