cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r179066 - /cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java /cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
Date Mon, 30 May 2005 14:43:30 GMT
Author: sylvain
Date: Mon May 30 07:43:29 2005
New Revision: 179066

URL: http://svn.apache.org/viewcvs?rev=179066&view=rev
Log:
Do not forget parameters coming from the URL in multipart requests

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java?rev=179066&r1=179065&r2=179066&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
Mon May 30 07:43:29 2005
@@ -116,18 +116,21 @@
      *
      */
     public String getParameter(String name) {
-        Object value = get(name);
-        String result = null;
-
-        if (value != null) {
-            if (value instanceof Vector) {
-                value = ((Vector) value).elementAt(0);
+        if (values != null) {
+            Object value = get(name);
+            String result = null;
+    
+            if (value != null) {
+                if (value instanceof Vector) {
+                    value = ((Vector) value).elementAt(0);
+                }
+    
+                result = value.toString();
             }
-
-            result = value.toString();
+            return result;
+        } else {
+            return super.getParameter(name);
         }
-
-        return result;
     }
 
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java?rev=179066&r1=179065&r2=179066&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java Mon May
30 07:43:29 2005
@@ -24,6 +24,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PushbackInputStream;
+import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -87,24 +88,44 @@
         this.characterEncoding = characterEncoding;
     }
 
-    public Hashtable getParts(int contentLength, String contentType, InputStream requestStream)
+    private void parseParts(int contentLength, String contentType, InputStream requestStream)
     throws IOException, MultipartException {
         if (contentLength > this.maxUploadSize) {
             throw new IOException("Content length exceeds maximum upload size");
         }
 
-        this.parts = new Hashtable();
         BufferedInputStream bufferedStream = new BufferedInputStream(requestStream);
         PushbackInputStream pushbackStream = new PushbackInputStream(bufferedStream, MAX_BOUNDARY_SIZE);
         TokenStream stream = new TokenStream(pushbackStream);
 
         parseMultiPart(stream, getBoundary(contentType));
 
-        return this.parts;    
+    }
+    
+    public Hashtable getParts(int contentLength, String contentType, InputStream requestStream)
+    throws IOException, MultipartException {
+        this.parts = new Hashtable();
+        parseParts(contentLength, contentType, requestStream);
+        return this.parts;
     }
     
     public Hashtable getParts(HttpServletRequest request) throws IOException, MultipartException
{
-        return getParts(request.getContentLength(), request.getContentType(), request.getInputStream());
   
+        this.parts = new Hashtable();
+        
+        // Copy all parameters coming from the request URI to the parts table.
+        // This happens when a form's action attribute has some parameters
+        Enumeration names = request.getParameterNames();
+        while(names.hasMoreElements()) {
+            String name = (String)names.nextElement();
+            String[] values = request.getParameterValues(name);
+            Vector v = new Vector(values.length);
+            for (int i = 0; i < values.length; i++) {
+                v.add(values[i]);
+            }
+            this.parts.put(name, v);
+        }
+        parseParts(request.getContentLength(), request.getContentType(), request.getInputStream());
   
+        return this.parts;    
     }
     
     /**



Mime
View raw message