You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Dominique Pfister (JIRA)" <ji...@apache.org> on 2008/01/14 10:39:34 UTC

[jira] Created: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
-----------------------------------------------------------------------------------------------------

                 Key: SLING-152
                 URL: https://issues.apache.org/jira/browse/SLING-152
             Project: Sling
          Issue Type: Bug
          Components: Core
            Reporter: Dominique Pfister


In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12559027#action_12559027 ] 

Bertrand Delacretaz commented on SLING-152:
-------------------------------------------

In revision 612087, I have rewritten ParameterSupport.parseFormEncodedPost to read parameters from the ServletRequest directly (needed this to make my usling-webapp integration tests work).

For now this uses Util.ENCODING_DEFAULT as the encoding.

> POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-152
>                 URL: https://issues.apache.org/jira/browse/SLING-152
>             Project: Sling
>          Issue Type: Bug
>          Components: Core
>            Reporter: Dominique Pfister
>
> In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560418#action_12560418 ] 

Bertrand Delacretaz commented on SLING-152:
-------------------------------------------

FWIW, my usling-webapp integration tests (which use both multipart and form-encoded POSTs) run fine with revision 613182, so after your changes.

> POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-152
>                 URL: https://issues.apache.org/jira/browse/SLING-152
>             Project: Sling
>          Issue Type: Bug
>          Components: Core
>            Reporter: Dominique Pfister
>            Assignee: Felix Meschberger
>
> In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger reassigned SLING-152:
---------------------------------------

    Assignee: Felix Meschberger

> POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-152
>                 URL: https://issues.apache.org/jira/browse/SLING-152
>             Project: Sling
>          Issue Type: Bug
>          Components: Core
>            Reporter: Dominique Pfister
>            Assignee: Felix Meschberger
>
> In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved SLING-152.
-------------------------------------

    Resolution: Fixed

Removing the parsing of all parameters provided by the servlet container. This not only comprises the url encoded input
stream data but also the query parameters from the request line. We just take what we get from the servlet container, apply our encoding (if any).

We still keep the parsing of multipart/form-data POST request data, as this is never handled by the servlet container according to the Servlet API spec.

Fixed in Rev. 613180.

Please close this issue, if this fixes your problems. Thanks.

> POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-152
>                 URL: https://issues.apache.org/jira/browse/SLING-152
>             Project: Sling
>          Issue Type: Bug
>          Components: Core
>            Reporter: Dominique Pfister
>            Assignee: Felix Meschberger
>
> In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

Posted by "Dominique Pfister (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12558560#action_12558560 ] 

Dominique Pfister commented on SLING-152:
-----------------------------------------

Thanks for the clarification. It is probably safe to assume that a compliant servlet container will exactly do that, looking at SRV.4.9: 

The default encoding of a request the container uses to create the request reader and parse POST data must be "ISO-8859-1" if none has been specified by the client request.


> POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-152
>                 URL: https://issues.apache.org/jira/browse/SLING-152
>             Project: Sling
>          Issue Type: Bug
>          Components: Core
>            Reporter: Dominique Pfister
>
> In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12558558#action_12558558 ] 

Alexander Klimetschek commented on SLING-152:
---------------------------------------------

My (hopefully helpful) experiences with this topic can be found here: http://cocoon.apache.org/2.2/1366_1_1.html

Most notably does Jetty use UTF-8 encoding by default and not ISO-8859-1 as defined by the servlet engine spec, which is kinda hard to find out. In the end the only way to do it reliably is to explicitly set UTF-8 encoding everywhere (ie. in the HTTP content type and meta tag content-type). UTF-8 is assumed to be the best encoding practically, but it should be configurable for the Sling admin anyway.

> POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-152
>                 URL: https://issues.apache.org/jira/browse/SLING-152
>             Project: Sling
>          Issue Type: Bug
>          Components: Core
>            Reporter: Dominique Pfister
>
> In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-152) POST parameters are read from request body even when contentType is application/x-www-form-urlencoded

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12558557#action_12558557 ] 

Felix Meschberger commented on SLING-152:
-----------------------------------------

In fact not only are these x-www-form-urlencoded parameters parsed by Sling, also the request line parameters are parsed by Sling.

Probably it would be better, if Sling would only parse the multipart/form-data requests and take other parameters from the servlet container.

FYI: Sling parses request line and x-www-form-urlencoded parameters to implement the parameter encoding scheme using the Form-Encoding parameter. We can of course workaround this, by assuming the servlet container parses the parameters in ISO-8859-1 encoding and we can just recode this on request.

> POST parameters are read from request body even when contentType is application/x-www-form-urlencoded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-152
>                 URL: https://issues.apache.org/jira/browse/SLING-152
>             Project: Sling
>          Issue Type: Bug
>          Components: Core
>            Reporter: Dominique Pfister
>
> In a POST request with content type application/x-www-form-urlencoded, Sling's internal ParameterSupport class (in sling-core) builds a parameter map by parsing the request body available via ServletRequest.getInputStream(). However, if some other component (e.g. a servlet filter) has already looked at some parameter, ServletRequest.getInputStream() will return an empty stream, compliant with Servlet API Specification 2.4 SRV.4.1.1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.