You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by "Florent Guillaume (JIRA)" <ji...@apache.org> on 2014/09/23 17:44:34 UTC

[jira] [Comment Edited] (CMIS-844) POSTHttpServletRequestWrapper should accommodate prior consumption of request body by a filter

    [ https://issues.apache.org/jira/browse/CMIS-844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14144929#comment-14144929 ] 

Florent Guillaume edited comment on CMIS-844 at 9/23/14 3:44 PM:
-----------------------------------------------------------------

In our example a filter could wrap the request, but the fact is that any piece of code in the stack prior to the POSTHttpServletRequestWrapper that does a request.getParameter will cause the body to be read. For instance, for Tomcat, org.apache.catalina.connector.Request#parseParameters does the job (and it has a multitude of encoding options). It's not reasonable or possible to expect all callers of request.getParameter to wrap the request.

So IMHO it's POSTHttpServletRequestWrapper which should not re-parse everything if it's already been parsed. Ron's suggestions look good to me.


was (Author: fguillaume):
In our example a filter could wrap the request, but the fact is that any piece of code in the stack prior to the POSTHttpServletRequestWrapper that does a request.getParameter will cause the body to be read. For instance, for Tomcat, org.apache.catalina.connector.Request#parseParameters does the job (and it has a multitude of encoding options). It's not reasonable or possible to expect all these to wrap the request just because they call request.getParameter.

So IMHO it's POSTHttpServletRequestWrapper which should not re-parse everything if it's already been parsed. Ron's suggestions look good to me.

> POSTHttpServletRequestWrapper should accommodate prior consumption of request body by a filter
> ----------------------------------------------------------------------------------------------
>
>                 Key: CMIS-844
>                 URL: https://issues.apache.org/jira/browse/CMIS-844
>             Project: Chemistry
>          Issue Type: Bug
>          Components: opencmis-server
>    Affects Versions: OpenCMIS 0.12.0
>            Reporter: Ron Gavlin
>            Assignee: Florian Müller
>
> POSTHttpServletRequestWrapper should accommodate prior consumption of the request body by a filter.
> The 0.7.0 release provided this accommodation. This appears to have been broken by the major post-0.7.0 refactoring.
> The following POSTHttpServletRequestWrapper constructor modification fixes the problem:
> {code}
> ...
>         if (isMultipart) {
> ...
>         } else {
>             // form data processing
>             StringBuilder sb = new StringBuilder();
>             InputStreamReader sr = new InputStreamReader(request.getInputStream(), IOUtils.UTF8);
>             char[] buffer = new char[4096];
>             int c = 0;
>             while ((c = sr.read(buffer)) > -1) {
>                 sb.append(buffer, 0, c);
>             }
>             if (sb.length() < 3) {
>                 @SuppressWarnings("unchecked")
>                 Map<String, String[]> parameterMap = request.getParameterMap();
>                 getParameterMap().putAll(parameterMap);
>             } else {
>                 parseFormData(sb.toString());
>             }
>         }
> ...
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)