0c9488ab by Jerry Pommer

Issue #2757 - Workaround to make GETs work under Node.

1 parent 6235725a
...@@ -119,37 +119,33 @@ public class DirectControlServlet extends HttpServlet { ...@@ -119,37 +119,33 @@ public class DirectControlServlet extends HttpServlet {
119 Debug.logInfo("PARAMETERS: " + paramList, module); 119 Debug.logInfo("PARAMETERS: " + paramList, module);
120 // Handle if this is a form post 120 // Handle if this is a form post
121 String contentType = request.getContentType(); 121 String contentType = request.getContentType();
122 if (contentType != null && contentType.indexOf("x-www-form-urlencoded") != -1) { 122 method = request.getParameter("_method");
123 method = request.getParameter("_method"); 123 String httpMethod = request.getMethod();
124 String httpMethod = request.getMethod(); 124 if (method == null && httpMethod != null) method = httpMethod;
125 if (method == null && httpMethod != null) method = httpMethod; 125 Debug.logInfo("Method: HTTP(" + httpMethod + ") embedded(" + method + ")", module);
126 Debug.logInfo("Method: HTTP(" + httpMethod + ") embedded(" + method + ")", module); 126 if (method == null) method = "GET";
127 if (method == null) method = "GET"; 127 // If this is a backbone PUT/DELETE emulated call then handle it
128 // If this is a backbone PUT/DELETE emulated call then handle it 128 if (request.getParameter("model") != null) {
129 if (request.getParameter("model") != null) {
130 // if (!"CALL".equals(method)) context.put("_method", method); 129 // if (!"CALL".equals(method)) context.put("_method", method);
131 JSON json = new JSON(new StringReader(request.getParameter("model"))); 130 JSON json = new JSON(new StringReader(request.getParameter("model")));
132 Map<String,Object> items = json.JSONObject(); 131 Map<String,Object> items = json.JSONObject();
133 for (String key : items.keySet()) { 132 for (String key : items.keySet()) {
134 if (!"sessionId".equals(key) && !"_method".equals(key)) { 133 if (!"sessionId".equals(key) && !"_method".equals(key)) {
135 context.put(key, items.get(key)); 134 context.put(key, items.get(key));
136 Debug.logInfo(">parameter '" + key + "'=" + items.get(key), module); 135 Debug.logInfo(">parameter '" + key + "'=" + items.get(key), module);
137 }
138 }
139 } else {
140 for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
141 String param = params.nextElement();
142 Object[] values = request.getParameterValues(param);
143 if (!"sessionId".equals(param) && !"_method".equals(param)) {
144 context.put(param, values.length == 1 ? values[0] : values);
145 Debug.logInfo("!parameter '" + param + "'=" + context.get(param), module);
146 }
147 } 136 }
148 } 137 }
149 } else { 138 } else {
150 Debug.logInfo("Unsupported form encoding", module); 139 for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
140 String param = params.nextElement();
141 Object[] values = request.getParameterValues(param);
142 if (!"sessionId".equals(param) && !"_method".equals(param)) {
143 context.put(param, values.length == 1 ? values[0] : values);
144 Debug.logInfo("!parameter '" + param + "'=" + context.get(param), module);
145 }
146 }
151 } 147 }
152 148
153 // If there is a mapping for this pathInfo, run the corresponding service 149 // If there is a mapping for this pathInfo, run the corresponding service
154 // otherwise, return an error 150 // otherwise, return an error
155 String serviceName = serviceURLMappings.get(pathInfo + "#" + method); 151 String serviceName = serviceURLMappings.get(pathInfo + "#" + method);
......