Skip to content
Permalink
Browse files
Improved: Change 'restMethod' by '_method' in request parameters
(OFBIZ-11332)

When we analyse a request method, we currently check the parameter "restMethod".
Mathieu Lirzin propose [1] to use "_method" instead to use a parameter name more generic

I create a new function UtilHttp.getRequestMethod() to centralize the request method resolution.

[1] https://issues.apache.org/jira/browse/OFBIZ-11007?focusedCommentId=17012712&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17012712
  • Loading branch information
nmalin committed Jan 29, 2020
1 parent fac12a4 commit 11cf350302015d1210b9f663cb9c68339701a3f8
@@ -695,6 +695,17 @@ public static String getFullRequestUrl(HttpServletRequest request) {
return requestUrl.toString();
}

/** Resolve the method send with the request.
* check first the parameter _method before return the request method
* @param request
* @return
*/
public static String getRequestMethod(HttpServletRequest request) {
return request.getParameter("_method") != null ?
request.getParameter("_method") :
request.getMethod();
}

public static Locale getLocale(HttpServletRequest request, HttpSession session, Object appDefaultLocale) {
// check session first, should override all if anything set there
Object localeObject = session != null ? session.getAttribute("locale") : null;
@@ -260,8 +260,7 @@ public void doRequest(HttpServletRequest request, HttpServletResponse response,
// The "overriddenView" attribute is set by resolveURI when necessary.
String overrideViewUri = (String) request.getAttribute("overriddenView");

String restMethod = request.getParameter("restMethod");
String method = (restMethod != null) ? restMethod : request.getMethod();
String method = UtilHttp.getRequestMethod(request);
RequestMap requestMap = resolveMethod(method, rmaps).orElseThrow(() -> {
String msg = UtilProperties.getMessage("WebappUiLabels", "RequestMethodNotMatchConfig",
UtilMisc.toList(requestUri, method), UtilHttp.getLocale(request));

0 comments on commit 11cf350

Please sign in to comment.