camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit Patel (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (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 Wed, 11 Jan 2012 20:49:39 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-4871?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Amit Patel updated CAMEL-4871:
------------------------------

    Labels: api-change  (was: patch)

We need new release to resolve this issue.
                
> 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

        

Mime
View raw message