Hi

So are you asking for how to configure the http client to follow redirects?

You use camel-http, so you need to find out how it does redirects

On Tue, May 10, 2022 at 3:46 PM Michael Rambichler
<mich...@rambichler.at> wrote:
>
> Hi Team,
>
> I hope someone can help us.
>
> We have to do a simple rest callout with POST method and http
> as producercomponent:
> If we use POST as method, the redirect in the http component is not
> fulfilled. (If we use GET it works)
>
> After some investigation we realized that we have to configure the
> http-client to use LaxRedirectStrategy
> But I have no idea how to access the client within camel.
>
> Do you have any ideas?
>
> Simple TestRoute:
>
> protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>
>                 restConfiguration()
>                         .producerComponent("http")
>                         .host("localhost")
>                         .port((Integer) parameters.get("port"));
>
>                 from("direct:start")
>
> .to("rest:POST:users/{id}/basic?throwExceptionOnFailure=false")
>                         .log(LoggingLevel.INFO, "Received body : ${body}")
>                         .to("mock:result");
>
>             }
>         };
>
>
> @Override
> @BeforeEach
> public void setUp() throws Exception {
>     super.setUp();
>
>     redirectServer = ServerBootstrap.bootstrap()
>             .setListenerPort((Integer)parameters.get("port2"))
>             .setHttpProcessor(getHttpProcessor())
>             .registerHandler("/*", new SimpleHandler("Donald Duck"))
>             .create();
>     redirectServer.start();
>
>     localServer = ServerBootstrap.bootstrap()
>             .setListenerPort((Integer)parameters.get("port"))
>             .setHttpProcessor(getHttpProcessor())
>             .registerHandler("/users/*", redirectTo(302,
> "/redirected", redirectServer))
>             .create();
>     localServer.start();



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to