You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jay mann (JIRA)" <ji...@apache.org> on 2016/05/13 22:50:13 UTC

[jira] [Created] (CAMEL-9968) camel restlet not populating body form parameters correctly for x-www-form-urlencoded

Jay mann created CAMEL-9968:
-------------------------------

             Summary: 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


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)