[
https://issues.apache.org/jira/browse/CAMEL-9968?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-9968.
--------------------------------
Resolution: Fixed
Assignee: Claus Ibsen
Thanks for the PR
> camel restlet not populating body form parameters correctly for
> x-www-form-urlencoded
> -------------------------------------------------------------------------------------
>
> Key: CAMEL-9968
> URL: https://issues.apache.org/jira/browse/CAMEL-9968
> Project: Camel
> Issue Type: Bug
> Components: camel-restlet
> Affects Versions: 2.17.1
> Reporter: Jay mann
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 2.17.2, 2.18.0
>
>
> Currently for x-www-form-urlencoded post request camel puts the body into a
> form key with a null value:
> {code}
> if ((Method.PUT == method || Method.POST == method) &&
> MediaType.APPLICATION_WWW_FORM.equals(mediaType, true)) {
> form = new Form();
> // must use string based for forms
> String body = exchange.getIn().getBody(String.class);
> if (body != null) {
> form.add(body, null);
> }
> }
> {code}
> Which results in a body like this:
> name=jay&password=secret
> ending up with a form parameter looking like this:
> name%3Djay%26password%3Dsecret=null
> I think something like this should be used to correctly set the key values.
> {code}
> if ((Method.PUT == method || Method.POST == method) &&
> MediaType.APPLICATION_WWW_FORM.equals(mediaType, true)) {
> form = new Form();
> // must use string based for forms
> String body = exchange.getIn().getBody(String.class);
> if (body != null) {
> List<NameValuePair> pairs = URLEncodedUtils.parse(body,
> Charset.forName("UTF-8"));
> for(NameValuePair p : pairs){
> form.add(p.getName(), p.getValue());
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)