You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Amit <am...@gmail.com> on 2013/10/30 15:09:33 UTC

Camel-HTTP4:2.11.2:ContentType does not returns "multipart/form-data;boundary=---------------------------j2radvtrk"

I found the issue in camel-http4 component. The
HttpProducer.createRequestEntity method has been changed to parse the
contentType. The ContentType.parse method returns "multipart/form-data"
instead of
"multipart/form-data;boundary=---------------------------j2radvtrk". If you
change HttpProducer.createRequestEntity to use ContentType.create method it
works fine. 


We have below test routes does not work because of above issue.

<route xmlns="http://camel.apache.org/schema/spring" trace="true">
  <from uri="servlet:///test/1.0/testPOST"/>
    <removeHeaders pattern="*"/>
    <setProperty propertyName="boundary">
        <groovy>
            import org.apache.commons.lang.RandomStringUtils;

            String charset = (('a'..'z') + ('0'..'9')).join();
            Integer length = 9;
            return "---------------------------" +
RandomStringUtils.random(length, charset.toCharArray());
        </groovy>
    </setProperty>
    <setHeader headerName="Content-Type">
        <simple>multipart/form-data;boundary=${property.boundary}</simple>
    </setHeader>
    <setHeader headerName="Exchange.HTTP_URI">
        <constant>http4://httpbin.org/post</constant>
    </setHeader>
    <setHeader headerName="CamelHttpMethod">
        <constant>POST</constant>
    </setHeader>
    <setBody>
        <groovy>
        
        </groovy>
    </setBody>
    <to
uri="http4://httpbin?httpClient.cookiePolicy=ignoreCookies&amp;httpClient.soTimeout=30000&amp;httpClient.connectionTimeout=30000"/>
    <removeProperty propertyName="boundary"/>
    <setHeader headerName="Content-Type">
        <constant>application/json</constant>
    </setHeader>
</route>




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-HTTP4-2-11-2-ContentType-does-not-returns-multipart-form-data-boundary-j2radvtrk-tp5742407.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel-HTTP4:2.11.2:ContentType does not returns "multipart/form-data;boundary=---------------------------j2radvtrk"

Posted by Amit <am...@gmail.com>.
I have created a JIRA ticket CAMEL-6926 and attached a patch.


Thanks,
Amit Patel



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-HTTP4-2-11-2-ContentType-does-not-returns-multipart-form-data-boundary-j2radvtrk-tp5742407p5742496.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel-HTTP4:2.11.2:ContentType does not returns "multipart/form-data;boundary=---------------------------j2radvtrk"

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Can you log a JIRA ticket?
Also if you have a fix then you are welcome to provide a patch.
http://camel.apache.org/support


On Wed, Oct 30, 2013 at 3:09 PM, Amit <am...@gmail.com> wrote:
> I found the issue in camel-http4 component. The
> HttpProducer.createRequestEntity method has been changed to parse the
> contentType. The ContentType.parse method returns "multipart/form-data"
> instead of
> "multipart/form-data;boundary=---------------------------j2radvtrk". If you
> change HttpProducer.createRequestEntity to use ContentType.create method it
> works fine.
>
>
> We have below test routes does not work because of above issue.
>
> <route xmlns="http://camel.apache.org/schema/spring" trace="true">
>   <from uri="servlet:///test/1.0/testPOST"/>
>     <removeHeaders pattern="*"/>
>     <setProperty propertyName="boundary">
>         <groovy>
>             import org.apache.commons.lang.RandomStringUtils;
>
>             String charset = (('a'..'z') + ('0'..'9')).join();
>             Integer length = 9;
>             return "---------------------------" +
> RandomStringUtils.random(length, charset.toCharArray());
>         </groovy>
>     </setProperty>
>     <setHeader headerName="Content-Type">
>         <simple>multipart/form-data;boundary=${property.boundary}</simple>
>     </setHeader>
>     <setHeader headerName="Exchange.HTTP_URI">
>         <constant>http4://httpbin.org/post</constant>
>     </setHeader>
>     <setHeader headerName="CamelHttpMethod">
>         <constant>POST</constant>
>     </setHeader>
>     <setBody>
>         <groovy>
>
>         </groovy>
>     </setBody>
>     <to
> uri="http4://httpbin?httpClient.cookiePolicy=ignoreCookies&amp;httpClient.soTimeout=30000&amp;httpClient.connectionTimeout=30000"/>
>     <removeProperty propertyName="boundary"/>
>     <setHeader headerName="Content-Type">
>         <constant>application/json</constant>
>     </setHeader>
> </route>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-HTTP4-2-11-2-ContentType-does-not-returns-multipart-form-data-boundary-j2radvtrk-tp5742407.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen