You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org> on 2012/02/24 16:52:49 UTC
[jira] [Commented] (CAMEL-4871) Request with Content-Type=
application/x-www-form-urlencoded throws "Cannot read request parameters
due Invalid parameter, expected to be a pair but was " when body is empty.
[ https://issues.apache.org/jira/browse/CAMEL-4871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13215695#comment-13215695 ]
Claus Ibsen commented on CAMEL-4871:
------------------------------------
Amit, can you re-attach the file attachments and mark [x] in grant license to Apache. Otherwise we cannot use your work.
> Request with Content-Type= application/x-www-form-urlencoded throws "Cannot read request parameters due Invalid parameter, expected to be a pair but was " when body is empty.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-4871
> URL: https://issues.apache.org/jira/browse/CAMEL-4871
> Project: Camel
> Issue Type: Bug
> Components: camel-http
> Affects Versions: 2.8.0
> Reporter: Amit Patel
> Labels: api-change
> Attachments: DefaultHttpBinding.java
>
>
> ISSUE
> -----------
> When CAMEL Servlet component receiving request with Content-Type= application/x-www-form-urlencoded. as below it throws Cannot read request parameters due Invalid parameter, expected to be a pair but was " when body is empty.
> Request
> ------------
> <html>
> </head>
> <body>
> <form method="post" action="http://test/assertionConsumer/1.0">
> <div>
> <input type="hidden" name="ID" value="fim page" />
> <input type="hidden" name="RelayState" value="http://dev.ecosys.com?count=id-afc417c792b413bd0208e2f7454fd030" />
> <input type="hidden" name="SAMLResponse" value="PHNhbWxwOlJlc3=" />
> </div>
> </form>
> <span id="user_msg"></span>
> <script type="text/javascript">sso();</script>
> </body>
> </html>
> RESOLUTION
> -------------
> Added defensive check, body is not null and not blank, to avoid Invalid parameter exception. I've updated org.apache.camel.component.http.DefaultHttpBinding class for that.
> // Push POST form params into the headers to retain compatibility
> // with DefaultHttpBinding
> String body = message.getBody(String.class);
> //Added defensive check, body is not null and not blank, to avoid Invalid parameter exception. ( My changes)
> if (body != null && !body.equals("")) {
> for (String param : body.split("&")) {
> String[] pair = param.split("=", 2);
> if (pair.length == 2) {
> String name = URLDecoder.decode(pair[0], charset);
> String value = URLDecoder.decode(pair[1], charset);
> if (headerFilterStrategy != null
> && !headerFilterStrategy
> .applyFilterToExternalHeaders(name,
> value, message.getExchange())) {
> HttpHelper.appendHeader(headers, name, value);
> }
> } else {
> throw new IllegalArgumentException(
> "Invalid parameter, expected to be a pair but was "
> + param);
> }
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira