camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jay mann (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-9968) camel restlet not populating body form parameters correctly for x-www-form-urlencoded
Date Wed, 18 May 2016 00:24:12 GMT

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

Jay mann commented on CAMEL-9968:
---------------------------------

PR #985 submitted.

> 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
>            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)

Mime
View raw message