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] [Created] (CAMEL-9968) camel restlet not populating body form parameters correctly for x-www-form-urlencoded
Date Fri, 13 May 2016 22:50:13 GMT
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)

Mime
View raw message