Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.17.1
-
None
-
Unknown
Description
Currently for x-www-form-urlencoded post request camel puts the body into a form key with a null value:
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); } }
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.
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()); } } }