camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (Issue Comment Edited) (JIRA)" <j...@apache.org>
Subject [jira] [Issue Comment Edited] (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.
Date Tue, 28 Feb 2012 16:07:47 GMT

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

Claus Ibsen edited comment on CAMEL-4871 at 2/28/12 4:06 PM:
-------------------------------------------------------------

I fixed this using not empty check, on the camel-http and camel-http4 components.
                
      was (Author: davsclaus):
    I fixed this using not empty check
                  
> 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
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.9.1, 2.10.0
>
>         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

        

Mime
View raw message