I have a simple Camel Route which processes the incoming Http request and then routes to other Http consumers based on the Resource path. Everything works fine but I hit the java.net.URISyntaxException: Illegal character in path when used a space in the path. Other special characters seem to work fine.
I am building a RESTful APIs and currently using the browser to test my APIs.
Here is the Spring DSL of my route:
<route id="API">
<from uri="jetty:http://0.0.0.0/api?matchOnUriPrefix=true"/>
<bean ref="basicAuthBean"/>
<choice>
<when>
<simple>${in.header.CamelHttpPath} contains 'blah1'</simple>
<to uri="http://localhost:10001/api?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
</when>
<when>
<simple>${in.header.CamelHttpPath} contains 'blah2'</simple>
<to uri="http://localhost:10002/api?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
</when>
</choice>
</route>
I enabled trace on the Camel Context and found that the CamelHttpPath had already replaced the escape character "%20" with a space. I also saw that there was CamelHttpUri which had not escaped the special character.
As a hack in my Spring DSL I added the following before the choice element:
<setHeader headerName="CamelHttpPath">
<simple>${in.header.CamelHttpUri}</simple>
</setHeader>
This solved my problem but I am pretty sure there is a better way to do this. Did I miss setting some properties or is my route DSL not accurate?
Also, what is the difference between the CamelHttpPath and CamelHttpUri?
I should also mention that I am using the Camel Context in Apache ServiceMix 4.4.2 and the Camel Version used is 2.8.5.
Thanks in advance for the help!
I think we have fixed this in later Camel releases due to be released like Camel 2.10.4 etc. I remember working on that space fix. https://issues.apache.org/jira/browse/CAMEL-5504
As Camel 2.8.x is no longer supported you would need to patch the issue yourself. Or upgrade to ServiceMix 4.5.0 which includes Camel 2.10.3.