Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using URI that contains underscore with Camel HTTP4

We are trying to use Apache Camel 2.16.3 to push some data to a third-party HTTP endpoint. We are using HTTP4 Component. We are setting the uri, method and query params as headers in the message. However, the endpoint contains an underscore (_) and we are getting an exception like this:

Caused by: java.lang.IllegalArgumentException: Invalid uri: https://x_y.something.com/somePath?q_one=XXXX&q_two=YYYYY. If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: Endpoint[https4://placeholder?throwExceptionOnFailure=false]

I have been researching a bit and it looks like that _ is something that should not be there in the URI. This website actually says that https://x_y.something.com/somePath is invalid but https://xy.something.com/somePath is valid.

Since I cannot change the third-party endpoint, is it possible to escape the underscore somehow? If not, is there any other solution or we need to abandon Apache Camel for this?

like image 525
hveiga Avatar asked Oct 29 '22 22:10

hveiga


1 Answers

EDIT Without seeing a code example I cannot be sure what the root cause is, but if I understand correctly, you are sending an HTTP request to an akka actor which is consuming from a Camel endpoint. My guess is that you're probably not populating the headers correctly - regardless of what the original HTTP4 endpoint looks like, Exchange.HTTP_URI header override will always take precedence. For example, this works perfectly fine:

from("jetty:http://localhost:9090/path")
    .routeId("jetty_server")
    .log("${body}");

from("timer:sender?delay=3000&period=5000")
    .setBody().constant("Ping!")
    .setHeader(Exchange.HTTP_URI, constant("http://localhost:9090/path"))
    .to("http4:x_y.something.com:9090/path?q_one=XXXX&q_two=YYYYY");

So my guess is that it's not a Camel issue.

like image 69
Miloš Milivojević Avatar answered Dec 11 '22 04:12

Miloš Milivojević