summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPiotr Janik2011-07-04 08:08:07 (EDT)
committer Szymon Brandys2011-07-04 08:08:07 (EDT)
commit0f7e4749fe036c0cf553890c304be94f1a0269e6 (patch)
treef82ebc44d66b6c5f391e28b931f3ea31c6c787c6
parent7f1940dd9724aa637638f36a2cea16fa1a599e3f (diff)
downloadorg.eclipse.orion.server-0f7e4749fe036c0cf553890c304be94f1a0269e6.zip
org.eclipse.orion.server-0f7e4749fe036c0cf553890c304be94f1a0269e6.tar.gz
org.eclipse.orion.server-0f7e4749fe036c0cf553890c304be94f1a0269e6.tar.bz2
bug 350424 - [client] wrong request for file save
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350424
-rw-r--r--bundles/org.eclipse.orion.server.core/src/org/eclipse/orion/internal/server/core/IOUtilities.java30
-rw-r--r--bundles/org.eclipse.orion.server.servlets/src/org/eclipse/orion/internal/server/servlets/file/FileHandlerV1.java2
2 files changed, 31 insertions, 1 deletions
diff --git a/bundles/org.eclipse.orion.server.core/src/org/eclipse/orion/internal/server/core/IOUtilities.java b/bundles/org.eclipse.orion.server.core/src/org/eclipse/orion/internal/server/core/IOUtilities.java
index 64f17e3..9e3624e 100644
--- a/bundles/org.eclipse.orion.server.core/src/org/eclipse/orion/internal/server/core/IOUtilities.java
+++ b/bundles/org.eclipse.orion.server.core/src/org/eclipse/orion/internal/server/core/IOUtilities.java
@@ -12,6 +12,8 @@ package org.eclipse.orion.internal.server.core;
import java.io.*;
+import javax.servlet.http.HttpServletRequest;
+
/**
* Various static helper methods for I/O processing.
*/
@@ -53,6 +55,34 @@ public class IOUtilities {
}
/**
+ * Returns the value of a request parameter as a String, or null if
+ * the parameter does not exist in the query string.
+ *
+ * Method is similar to HttpServletRequest.getParameter(String name) method, but it does not
+ * interfere with HttpServletRequest.getInputStream() and HttpServletRequest.getReader().
+ * @param request a request object
+ * @param name a String specifying the name of the parameter
+ * @return a String representing the single value of the parameter
+ */
+ public static String getQueryParameter(HttpServletRequest request, String name) {
+ String queryString = request.getQueryString();
+ if (queryString == null)
+ return null;
+
+ for (String paramString : queryString.split("&")) {
+ if (paramString.startsWith(name)) {
+ String[] nameAndValue = paramString.split("=", 2);
+ if (nameAndValue.length == 2)
+ return nameAndValue[1];
+ else
+ return ""; // parameter has no value
+ }
+ }
+ // parameter not found
+ return null;
+ }
+
+ /**
* Closes a stream or reader and ignores any resulting exception. This is useful
* when doing cleanup in a finally block where secondary exceptions
* are not worth logging.
diff --git a/bundles/org.eclipse.orion.server.servlets/src/org/eclipse/orion/internal/server/servlets/file/FileHandlerV1.java b/bundles/org.eclipse.orion.server.servlets/src/org/eclipse/orion/internal/server/servlets/file/FileHandlerV1.java
index cdf060d..8b7490b 100644
--- a/bundles/org.eclipse.orion.server.servlets/src/org/eclipse/orion/internal/server/servlets/file/FileHandlerV1.java
+++ b/bundles/org.eclipse.orion.server.servlets/src/org/eclipse/orion/internal/server/servlets/file/FileHandlerV1.java
@@ -105,7 +105,7 @@ class FileHandlerV1 extends GenericFileHandler {
@Override
public boolean handleRequest(HttpServletRequest request, HttpServletResponse response, IFileStore file) throws ServletException {
try {
- String parts = request.getParameter("parts"); //$NON-NLS-1$
+ String parts = IOUtilities.getQueryParameter(request, "parts");
if (parts == null || "body".equals(parts)) { //$NON-NLS-1$
switch (getMethod(request)) {
case DELETE :