Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Fauth2020-10-26 11:59:27 +0000
committerDirk Fauth2020-10-26 14:33:43 +0000
commit1e93f990c6a684027294418cc729b5d4d2520fd7 (patch)
tree25db4e3d382671f0634b3622e4c72c1a16912d16
parentb26d6d429c0e6597ed495c67bc6bda8b58719438 (diff)
downloadrt.equinox.bundles-1e93f990c6a684027294418cc729b5d4d2520fd7.tar.gz
rt.equinox.bundles-1e93f990c6a684027294418cc729b5d4d2520fd7.tar.xz
rt.equinox.bundles-1e93f990c6a684027294418cc729b5d4d2520fd7.zip
Bug 567831 - Multipart collection parameter lostY20201026-1200I20201026-1850
Change-Id: I51f7d56a1e92d58e2a3b85dee4c73d6420e7b00b Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java2
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java146
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java75
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java7
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java13
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java3
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java20
11 files changed, 231 insertions, 43 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF
index 47025ad7b..9ca72654a 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: org.eclipse.equinox.http.servlet.tests
Bundle-Vendor: Eclipse.org - Equinox
Bundle-SymbolicName: org.eclipse.equinox.http.servlet.tests
-Bundle-Version: 1.7.0.qualifier
+Bundle-Version: 1.8.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Require-Bundle: org.junit;bundle-version="4.0"
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml b/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml
index cd5124c92..0386001b2 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.http.servlet.tests</artifactId>
- <version>1.7.0-SNAPSHOT</version>
+ <version>1.8.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<build>
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
index 04d624f7e..b03fceb35 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
@@ -26,6 +26,7 @@ import org.eclipse.equinox.http.servlet.tests.ServletTest;
import org.eclipse.equinox.http.servlet.tests.TestHttpServiceAndErrorPage;
import org.eclipse.equinox.http.servlet.tests.TestHttpServiceAndNamedServlet;
import org.eclipse.equinox.http.servlet.tests.TestUpload;
+import org.eclipse.equinox.http.servlet.tests.TestUploadWithParameter;
import org.eclipse.equinox.http.servlet.tests.Test_140_11_3;
import org.eclipse.equinox.http.servlet.tests.Test_140_2_17to22;
import org.eclipse.equinox.http.servlet.tests.Test_140_2_26to27;
@@ -99,6 +100,7 @@ import org.junit.runners.Suite.SuiteClasses;
TestHttpServiceAndErrorPage.class,
TestHttpServiceAndNamedServlet.class,
TestUpload.class,
+ TestUploadWithParameter.class,
ContextHelperCustomizerTests.class,
Bug500783_Test.class,
Bug562843_Test.class,
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java
new file mode 100644
index 000000000..cacc02e41
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Dirk Fauth and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 567831
+ ******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.Part;
+
+import org.eclipse.equinox.http.servlet.testbase.BaseTest;
+import org.junit.Test;
+
+public class TestUploadWithParameter extends BaseTest {
+
+ @Test
+ public void testUploadWithParameter() throws Exception {
+ final CountDownLatch receivedLatch = new CountDownLatch(1);
+ final HashMap<String, Object> contents = new HashMap<>();
+ final HashMap<String, String> contentsByKey = new HashMap<>();
+ setupUploadWithParameterServlet(receivedLatch, contents, contentsByKey);
+
+ postContentWithParameter(getClass().getResource("resource1.txt"), 201);
+ assertTrue(receivedLatch.await(5, TimeUnit.SECONDS));
+ assertEquals(2, contents.size());
+ assertEquals("Test", contents.get("single"));
+ assertNotNull(contents.get("multi"));
+ assertTrue(contents.get("multi") instanceof List);
+
+ @SuppressWarnings("unchecked")
+ List<String> multi = (List<String>) contents.get("multi");
+ assertEquals(3, multi.size());
+ assertTrue(multi.contains("One"));
+ assertTrue(multi.contains("Two"));
+ assertTrue(multi.contains("Three"));
+
+ assertEquals(2, contentsByKey.size());
+ assertEquals("Test", contentsByKey.get("single"));
+ assertEquals("One", contentsByKey.get("multi"));
+ }
+
+ private void setupUploadWithParameterServlet(CountDownLatch receivedLatch, Map<String, Object> contents, Map<String, String> contentsByKey) {
+ final Dictionary<String,Object> servletProps = new Hashtable<>();
+ servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, "/post");
+ servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED, Boolean.TRUE);
+ servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE, 1024L);
+
+ @SuppressWarnings("serial")
+ final Servlet uploadServlet = new HttpServlet() {
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException, ServletException {
+
+ try {
+ // check if the multi values are sent as post parameter in the multipart request
+ ArrayList<String> collected = new ArrayList<>();
+ for (Part supportPart : req.getParts()) {
+ if (supportPart.getName().equals("multi")) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(supportPart.getInputStream()))) {
+ List<String> collect = reader.lines().collect(Collectors.toList());
+ if (collect != null && !collect.isEmpty()) {
+ collected.addAll(collect);
+ }
+ }
+ } else if (supportPart.getName().equals("single")) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(supportPart.getInputStream()))) {
+ contents.put("single", reader.readLine());
+ }
+ }
+ }
+ if (!collected.isEmpty()) {
+ contents.put("multi", collected);
+ }
+
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(req.getPart("single").getInputStream()))) {
+ contentsByKey.put("single", reader.readLine());
+ }
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(req.getPart("multi").getInputStream()))) {
+ contentsByKey.put("multi", reader.readLine());
+ }
+
+ resp.setStatus(201);
+ } finally {
+ receivedLatch.countDown();
+ }
+
+ }
+ };
+
+ long before = this.getHttpRuntimeChangeCount();
+ registrations.add(getBundleContext().registerService(
+ Servlet.class.getName(), uploadServlet, servletProps));
+ this.waitForRegistration(before);
+ }
+
+ private void postContentWithParameter(final URL resource, final int expectedRT) throws IOException {
+ Map<String, List<Object>> header = new LinkedHashMap<>();
+ header.put("method", Arrays.<Object>asList("POST"));
+ header.put("text.txt", Arrays.<Object>asList(resource));
+
+ Map<String, Object> formFields = new LinkedHashMap<>();
+ formFields.put("single", "Test");
+ formFields.put("multi", Arrays.asList("One", "Two", "Three"));
+
+ Map<String, List<String>> result = requestAdvisor.upload("post", header, formFields);
+
+ assertEquals(expectedRT + "", result.get("responseCode").get(0));
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java
index 9fc74c6b8..37a39a958 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2019 IBM Corporation and others.
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Raymond Augé <raymond.auge@liferay.com> - Bug 436698
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 567831
*******************************************************************************/
package org.eclipse.equinox.http.servlet.tests.util;
@@ -30,6 +31,7 @@ import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.security.KeyStore;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -286,6 +288,10 @@ public class ServletRequestAdvisor extends Object {
}
public Map<String, List<String>> upload(String value, Map<String, List<Object>> headers) throws IOException {
+ return upload(value, headers, null);
+ }
+
+ public Map<String, List<String>> upload(String value, Map<String, List<Object>> headers, Map<String, Object> formFields) throws IOException {
String spec = createUrlSpec(value);
log("Requesting " + spec); //$NON-NLS-1$
URL url = new URL(spec);
@@ -309,11 +315,16 @@ public class ServletRequestAdvisor extends Object {
postFormURLEncoded(connection, (String)entryValue);
}
else {
- connection.setRequestProperty(entry.getKey(), (String)entryValue);
+ String property = connection.getRequestProperty(entry.getKey());
+ if (property == null) {
+ connection.setRequestProperty(entry.getKey(), (String)entryValue);
+ } else {
+ connection.setRequestProperty(entry.getKey(), property + "," + entryValue);
+ }
}
}
else if (entryValue instanceof URL) {
- uploadFileConnection(connection, entry.getKey(), (URL)entryValue);
+ uploadFileConnection(connection, entry.getKey(), (URL)entryValue, formFields);
}
else {
throw new IllegalArgumentException("only supports strings and files");
@@ -359,7 +370,8 @@ public class ServletRequestAdvisor extends Object {
}
}
- private void uploadFileConnection(HttpURLConnection connection, String param, URL file)
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void uploadFileConnection(HttpURLConnection connection, String param, URL file, Map<String, Object> formFields)
throws IOException {
String fileName = file.getPath();
@@ -370,14 +382,41 @@ public class ServletRequestAdvisor extends Object {
String CRLF = "\r\n";
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
- InputStream input = null;
- OutputStream output = null;
- PrintWriter writer = null;
-
- try {
- output = connection.getOutputStream();
- writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true);
-
+ try (InputStream input = file.openStream();
+ OutputStream output = connection.getOutputStream();
+ PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true);) {
+
+ // add optional parameter
+ if (formFields != null) {
+ formFields.entrySet().forEach(entry -> {
+ if (entry.getValue() instanceof Collection) {
+ ((Collection)entry.getValue()).forEach(value -> {
+ writer.append("--" + boundary);
+ writer.append(CRLF);
+ writer.append("Content-Disposition: form-data; name=\"" + entry.getKey() + "\"");
+ writer.append(CRLF);
+ writer.append("Content-Type: text/plain; charset=UTF-8");
+ writer.append(CRLF);
+ writer.append(CRLF);
+ writer.append((String) value);
+ writer.append(CRLF);
+ writer.flush();
+ });
+ } else {
+ writer.append("--" + boundary);
+ writer.append(CRLF);
+ writer.append("Content-Disposition: form-data; name=\"" + entry.getKey() + "\"");
+ writer.append(CRLF);
+ writer.append("Content-Type: text/plain; charset=UTF-8");
+ writer.append(CRLF);
+ writer.append(CRLF);
+ writer.append((String) entry.getValue());
+ writer.append(CRLF);
+ writer.flush();
+ }
+ });
+ }
+
writer.append("--" + boundary);
writer.append(CRLF);
writer.append("Content-Disposition: form-data; name=\"");
@@ -398,7 +437,6 @@ public class ServletRequestAdvisor extends Object {
writer.flush();
byte[] buf = new byte[64];
- input = file.openStream();
int c = 0;
while ((c = input.read(buf, 0, buf.length)) > 0) {
output.write(buf, 0, c);
@@ -414,17 +452,6 @@ public class ServletRequestAdvisor extends Object {
writer.append(CRLF);
writer.flush();
}
- finally {
- if (input != null) {
- input.close();
- }
- if (output != null) {
- output.close();
- }
- if (writer != null) {
- writer.close();
- }
- }
}
}
diff --git a/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF
index 01127fc2f..33bb60547 100644
--- a/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.equinox.http.servlet
-Bundle-Version: 1.6.600.qualifier
+Bundle-Version: 1.6.700.qualifier
Bundle-Activator: org.eclipse.equinox.http.servlet.internal.Activator
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/bundles/org.eclipse.equinox.http.servlet/pom.xml b/bundles/org.eclipse.equinox.http.servlet/pom.xml
index 82772b870..1c22ac16b 100644
--- a/bundles/org.eclipse.equinox.http.servlet/pom.xml
+++ b/bundles/org.eclipse.equinox.http.servlet/pom.xml
@@ -20,6 +20,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.http.servlet</artifactId>
- <version>1.6.600-SNAPSHOT</version>
+ <version>1.6.700-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java
index b3faf55d8..fe7acd0a0 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 Raymond Augé and others.
+ * Copyright (c) 2016, 2020 Raymond Augé and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,17 +10,18 @@
*
* Contributors:
* Raymond Augé <raymond.auge@liferay.com> - Bug 497271
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 567831
*******************************************************************************/
package org.eclipse.equinox.http.servlet.internal.multipart;
import java.io.IOException;
-import java.util.Map;
+import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Part;
public interface MultipartSupport {
- public Map<String, Part> parseRequest(HttpServletRequest request) throws IOException, ServletException;
+ public List<Part> parseRequest(HttpServletRequest request) throws IOException, ServletException;
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java
index c40ff87e0..8296b919a 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016, 2019 Raymond Augé and others.
+ * Copyright (c) 2016, 2020 Raymond Augé and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,13 +10,14 @@
*
* Contributors:
* Raymond Augé <raymond.auge@liferay.com> - Bug 497271
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 567831
*******************************************************************************/
package org.eclipse.equinox.http.servlet.internal.multipart;
import java.io.*;
import java.security.AccessControlContext;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -79,7 +80,7 @@ public class MultipartSupportImpl implements MultipartSupport {
}
@Override
- public Map<String, Part> parseRequest(HttpServletRequest request) throws IOException, ServletException {
+ public List<Part> parseRequest(HttpServletRequest request) throws IOException, ServletException {
if (upload == null) {
throw new IllegalStateException("Servlet was not configured for multipart!"); //$NON-NLS-1$
}
@@ -92,13 +93,13 @@ public class MultipartSupportImpl implements MultipartSupport {
throw new ServletException("Not a multipart request!"); //$NON-NLS-1$
}
- Map<String, Part> parts = new HashMap<String, Part>();
+ ArrayList<Part> parts = new ArrayList<Part>();
try {
for (Object item : upload.parseRequest(request)) {
DiskFileItem diskFileItem = (DiskFileItem)item;
- parts.put(diskFileItem.getFieldName(), new MultipartSupportPart(diskFileItem));
+ parts.add(new MultipartSupportPart(diskFileItem));
}
}
catch (FileUploadException fnfe) {
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java
index b40942dcb..ca5d433de 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java
@@ -12,6 +12,7 @@
* Cognos Incorporated - initial API and implementation
* IBM Corporation - bug fixes and enhancements
* Raymond Augé - bug fixes and enhancements
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 567831
*******************************************************************************/
package org.eclipse.equinox.http.servlet.internal.registration;
@@ -88,7 +89,7 @@ public class ServletRegistration extends EndpointRegistration<ServletDTO> {
return servletHolder.getServiceReference();
}
- public Map<String, Part> parseRequest(HttpServletRequest request) throws IOException, ServletException {
+ public List<Part> parseRequest(HttpServletRequest request) throws IOException, ServletException {
if (multipartSupport == null) {
throw new IOException("Servlet not configured for multipart!"); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java
index e7f5bc44a..f3e47f845 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2019 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2020 Cognos Incorporated, IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,6 +13,7 @@
* IBM Corporation - bug fixes and enhancements
* Raymond Augé <raymond.auge@liferay.com> - Bug 436698
* Arnaud Mergey <a_mergey@yahoo.fr> - Bug 497510
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 567831
*******************************************************************************/
package org.eclipse.equinox.http.servlet.internal.servlet;
@@ -34,7 +35,7 @@ public class HttpServletRequestWrapperImpl extends HttpServletRequestWrapper {
private final Deque<DispatchTargets> dispatchTargets = new LinkedList<DispatchTargets>();
private final HttpServletRequest request;
- private Map<String, Part> parts;
+ private List<Part> parts;
private final Lock lock = new ReentrantLock();
private static final Set<String> dispatcherAttributes = new HashSet<String>();
@@ -436,12 +437,21 @@ public class HttpServletRequestWrapperImpl extends HttpServletRequestWrapper {
@Override
public Part getPart(String name) throws IOException, ServletException {
- return getParts0().get(name);
+ if (name != null) {
+ Collection<Part> allParts = getParts();
+ for (Part part : allParts) {
+ if (name.equals(part.getName())) {
+ return part;
+ }
+ }
+ }
+
+ return null;
}
@Override
public Collection<Part> getParts() throws IOException, ServletException {
- return new ArrayList<Part>(getParts0().values());
+ return new ArrayList<Part>(getParts0());
}
public AsyncContext startAsync() throws IllegalStateException {
@@ -458,7 +468,7 @@ public class HttpServletRequestWrapperImpl extends HttpServletRequestWrapper {
throw new IllegalStateException("Async not supported by " + endpointRegistration); //$NON-NLS-1$
}
- private Map<String, Part> getParts0() throws IOException, ServletException {
+ private List<Part> getParts0() throws IOException, ServletException {
org.eclipse.equinox.http.servlet.internal.registration.ServletRegistration servletRegistration = getServletRegistration();
if (servletRegistration == null) {

Back to the top