Author: sohil.shah(a)jboss.com
Date: 2010-08-26 18:47:01 -0400 (Thu, 26 Aug 2010)
New Revision: 3944
Modified:
components/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/RpcServlet.java
Log:
JBEPP-393: Malformed Security token when adding gadgets
Modified:
components/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/RpcServlet.java
===================================================================
---
components/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/RpcServlet.java 2010-08-26
16:50:46 UTC (rev 3943)
+++
components/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/RpcServlet.java 2010-08-26
22:47:01 UTC (rev 3944)
@@ -31,6 +31,7 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
@@ -98,11 +99,23 @@
}
ServletInputStream is = request.getInputStream();
+
byte[] body = IOUtils.toByteArray(is);
- if (body.length != length) {
+ if(body.length == 0)
+ {
+ //Looks like the servlet input stream has already been read in its request
lifecycle
+ String bodyStr = request.getParameterMap().toString();
+ int index = bodyStr.lastIndexOf('=');
+ bodyStr = bodyStr.substring(1, index).trim();
+
+ body = bodyStr.getBytes();
+ }
+
+ if (body.length != length)
+ {
logger.info("Wrong size. Length: " + length + " real: " +
body.length);
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- return;
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ return;
}
Result result = process(request, response, body);
Show replies by date