You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2023/01/11 14:13:00 UTC

[jira] [Updated] (CAMEL-18840) camel-http - HTTP broken followRedirection

     [ https://issues.apache.org/jira/browse/CAMEL-18840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-18840:
--------------------------------
    Fix Version/s: 4.0

> camel-http - HTTP broken followRedirection 
> -------------------------------------------
>
>                 Key: CAMEL-18840
>                 URL: https://issues.apache.org/jira/browse/CAMEL-18840
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-http
>    Affects Versions: 3.20.0
>            Reporter: Valeriy Ak
>            Assignee: Claus Ibsen
>            Priority: Minor
>              Labels: camel-http
>             Fix For: 3.20.1, 3.21.0, 4.0
>
>
> Look like in 3.20.0 broken functionallity for disable follow redirections (HTTP 300-399 statuses) by set automatic-retries-disabled. Now need also set *RedirectHandlingDisabled*
>  
> Here simple example:
> {code:java}
> import org.apache.camel.CamelContext;
> import org.apache.camel.Exchange;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.http.HttpComponent;
> import org.apache.camel.impl.DefaultCamelContext;
> import static org.apache.camel.builder.endpoint.StaticEndpointBuilders.http;
> class Scratch {
>     public static void main(String[] args) throws Exception {
>         //1
>         CamelContext context1 = createContext(8080);
>         var httpComponent1 = context1.getComponent("http", HttpComponent.class);
>         httpComponent1.setFollowRedirects(false);
>         context1.start();
>         var response1 = context1.createProducerTemplate().requestBody("direct:http", "");
>         //Redirect to Apache Camel Page without any errors
>         System.out.println(response1);
>         //2
>         CamelContext context2 = createContext(8081);
>         var httpComponent2 = context2.getComponent("http", HttpComponent.class);
>         httpComponent2.setFollowRedirects(false);
>         httpComponent2.setAutomaticRetriesDisabled(true);
>         context2.start();
>         var response2 = context2.createProducerTemplate().requestBody("direct:http", "");
>         //Redirect to Apache Camel Page without any errors
>         System.out.println(response2);
>         //3
>         CamelContext context3 = createContext(8082);
>         var httpComponent3 = context3.getComponent("http", HttpComponent.class);
>         httpComponent3.setFollowRedirects(false);
>         httpComponent3.setAutomaticRetriesDisabled(true);
>         httpComponent3.setRedirectHandlingDisabled(true);
>         context3.start();
>         var response3 = context3.createProducerTemplate().requestBody("direct:http", "");
>         //work as expected - error throws
>         System.out.println(response3);
>     }
>     private static CamelContext createContext(int port) throws Exception {
>         CamelContext context = new DefaultCamelContext();
>         context.addRoutes(new RouteBuilder() {
>             @Override
>             public void configure() {
>                 restConfiguration().component("jetty").host("localhost").port(port);
>                 rest().get("test303").to("direct:addLocation");
>                 from("direct:addLocation")
>                         .setHeader("Location", constant("https://camel.apache.org"))
>                         .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(303));
>                 from("direct:http")
>                         .setHeader(Exchange.HTTP_METHOD, constant("GET"))
>                         .to(http("localhost:" + port + "/test303")
>                                 .bridgeEndpoint(true)
>                                 .throwExceptionOnFailure(true)
>                                 .advanced()
>                                 .okStatusCodeRange("200-299"))
>                         .convertBodyTo(String.class);
>             }
>         });
>         return context;
>     }
> } {code}
>  
>  * In version 3.11.1 exaption throws on 2 step with setAutomaticRetriesDisabled  (for run it - need remove setFollowRedirects)
>  * In version 3.20.0 exaption throws  {*}only on 3 step{*}.
>  
> Please fix it or add description of this new behavior to your documentaions.
> Also I don't understan how to use option *camel.component.http.follow-redirects* because seems it does not works as expected "Whether to the HTTP request should follow redirects."



--
This message was sent by Atlassian Jira
(v8.20.10#820010)