You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Willem Jiang (JIRA)" <ji...@apache.org> on 2010/03/01 14:45:44 UTC

[jira] Created: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Mixing jetty/http in a route screws up the URI used by HttpClient
-----------------------------------------------------------------

                 Key: CAMEL-2510
                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
             Project: Apache Camel
          Issue Type: Bug
    Affects Versions: 2.2.0, 2.1.0
            Reporter: Willem Jiang
             Fix For: 2.3.0


Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.

{code}
   public class JettyHttpTest extends CamelTestSupport {

    private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
    private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
    private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
    private String sourceProducerUri = "http://localhost:6323/myservice";

    @Test
    public void testGetRootPath() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hi! /someservice");

        template.sendBody("direct:root", "");

        assertMockEndpointsSatisfied();
    }
    
    @Test
    public void testGetWithRelativePath() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hi! /someservice/relative");
        
        template.sendBody("direct:relative", "");
        assertMockEndpointsSatisfied();
        
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {

                from(targetConsumerUri)
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
                            exchange.getOut().setBody("Hi! " + path);
                        }   
                    });

                from(sourceUri)
                    .to(targetProducerUri);

                from("direct:root")
                    .to(sourceProducerUri)
                    .to("mock:result");
                
                from("direct:relative")
                    .to(sourceProducerUri + "/relative")
                    .to("mock:result");

            }
        };
    }
}
{code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang resolved CAMEL-2510.
---------------------------------

    Resolution: Fixed

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang reassigned CAMEL-2510:
-----------------------------------

    Assignee: Willem Jiang

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang resolved CAMEL-2510.
---------------------------------

    Resolution: Fixed

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reopened CAMEL-2510:
--------------------------------


> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58016#action_58016 ] 

Willem Jiang commented on CAMEL-2510:
-------------------------------------

@Claus,

I need to make my change more clear, lets take the REST service as an example, the relative path could be used for URI template.
If we use the jetty and http component to build a bridge, my change will support it out of box.
{code}
from("jetty:http://localhost/input?matchOnUriPrefix=true").to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}

For the HttpProducer, our police is the message header of HTTP_PATH and HTTP_URI can override the http endpoint configuration, and we introduce the bridgeEndpoint option to ignore the message header of HTTP_URI.    
If you want to this route implement Roman's requirement, current solution could be 
rom("jetty:http://localhost/input?matchOnUriPrefix=true").setHeader(Exchange.HTTP_PATH, constant("")).to("http://localhost:8080/outservice?bridgeEndpoint=true");

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58016#action_58016 ] 

Willem Jiang edited comment on CAMEL-2510 at 3/4/10 8:11 AM:
-------------------------------------------------------------

@Claus,

I need to make my change more clear, lets take the REST service as an example, the relative path could be used for URI template.
If we use the jetty and http component to build a bridge, my change will support it out of box.
{code}
from("jetty:http://localhost/input?matchOnUriPrefix=true").to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}

For the HttpProducer, our police is the message header of HTTP_PATH and HTTP_URI can override the http endpoint configuration, and we introduce the bridgeEndpoint option to ignore the message header of HTTP_URI.    
If you want to this route implement Roman's requirement, current solution could be 
{code}
rom("jetty:http://localhost/input?matchOnUriPrefix=true").setHeader(Exchange.HTTP_PATH, constant("")).to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}

      was (Author: njiang):
    @Claus,

I need to make my change more clear, lets take the REST service as an example, the relative path could be used for URI template.
If we use the jetty and http component to build a bridge, my change will support it out of box.
{code}
from("jetty:http://localhost/input?matchOnUriPrefix=true").to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}

For the HttpProducer, our police is the message header of HTTP_PATH and HTTP_URI can override the http endpoint configuration, and we introduce the bridgeEndpoint option to ignore the message header of HTTP_URI.    
If you want to this route implement Roman's requirement, current solution could be 
rom("jetty:http://localhost/input?matchOnUriPrefix=true").setHeader(Exchange.HTTP_PATH, constant("")).to("http://localhost:8080/outservice?bridgeEndpoint=true");
  
> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=57971#action_57971 ] 

Willem Jiang commented on CAMEL-2510:
-------------------------------------

Hi Roma,

The change that I made is trying to support the http bridge out of box.

If you want to route the all the request which URI is start with "http://localhost:1234/route" to "http://localhost:4567/service",  camel need to lookup the request's HTTP_PATH to figure out the relative path and apply it to http producer to send the request.
The original code supports  this kind of route "http://localhost:1234" to "http://host:4567/service" , but doesn't supports the upper route.

For the header of HTTP_PATH and HTTP_URI, cxfbean is using it to support the JAXRS resource location.
  

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58015#action_58015 ] 

Claus Ibsen commented on CAMEL-2510:
------------------------------------

After digging a bit more I think we have an issue in Camel when you combine Jetty with Http, since Jetty will populate the Exchange with HTTP_* headers. And these headers influence when you invoke other http endpoints later in the route, as if you should *overrule* the endpoint uri.

We got a catch-22 situation since those HTTP_* headers should have been _informative_ and should not impact the routing.

Currently I cannot se an easy solution without breaking backwards comparability, but I also recon that not many Camel end users will use those HTTP_* headers in their routes.
So maybe we can change camel-jetty, to use other header keys, that dont clash.

Or the opposite that you must use HTTP_CUSTOM_* header to overrule. However this is a bigger change as Camel end users then must change their code.


> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58016#action_58016 ] 

Willem Jiang edited comment on CAMEL-2510 at 3/4/10 8:57 AM:
-------------------------------------------------------------

@Claus,

I need to make my change more clear, lets take the REST service as an example, the relative path could be used for URI template.
If we use the jetty and http component to build a bridge, my change will support it out of box.
{code}
from("jetty:http://localhost/input?matchOnUriPrefix=true").to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}

For the HttpProducer, our police is the message header of HTTP_PATH and HTTP_URI can override the http endpoint configuration, and we introduce the bridgeEndpoint option to ignore the message header of HTTP_URI.    
If you want to this route implement Roman's requirement, current solution could be 
{code}
rom("jetty:http://localhost/input?matchOnUriPrefix=true").removeHeader(Exchange.HTTP_PATH).to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}

      was (Author: njiang):
    @Claus,

I need to make my change more clear, lets take the REST service as an example, the relative path could be used for URI template.
If we use the jetty and http component to build a bridge, my change will support it out of box.
{code}
from("jetty:http://localhost/input?matchOnUriPrefix=true").to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}

For the HttpProducer, our police is the message header of HTTP_PATH and HTTP_URI can override the http endpoint configuration, and we introduce the bridgeEndpoint option to ignore the message header of HTTP_URI.    
If you want to this route implement Roman's requirement, current solution could be 
{code}
rom("jetty:http://localhost/input?matchOnUriPrefix=true").setHeader(Exchange.HTTP_PATH, constant("")).to("http://localhost:8080/outservice?bridgeEndpoint=true");
{code}
  
> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Roman Kalukiewicz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=57953#action_57953 ] 

Roman Kalukiewicz commented on CAMEL-2510:
------------------------------------------

Should we really have such assertion in {{testGetWithRelativePath()}} test?

I believe we should have {{"Hi! /someservice"}} returned, not {{"Hi! /someservice/relative"}} and no {{matchOnUriPrefix}} should be required on {{targetConsumerUri}}.

In other words I believe, that by default we shouldn't propagate HTTP_PATH or HTTP_URI at all from one endpoint to the other, because by default it is not what people would expect. I would propose having two different header names for overriding path for producer, and informative headers for requests received.from consumers.

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58013#action_58013 ] 

Claus Ibsen commented on CAMEL-2510:
------------------------------------

I to think there is something wrong with this commit.

The changed code in HttpProducerHelper makes other situations fail now. 
And why do you have this relative check?

The 2 urls should IMHO always be considered absolute when bridging.

I do think we need to find a new solution for this and revert the current change.

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-2510) Mixing jetty/http in a route screws up the URI used by HttpClient

Posted by "Roman Kalukiewicz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=57996#action_57996 ] 

Roman Kalukiewicz commented on CAMEL-2510:
------------------------------------------

I believe I was misunderstood :)

I'm not saying that we shouldn't send HTTP_PATH or HTTP_URI headers at all. I believe they are needed definitely (as you wrote earlier). I just believe that by default some other headers should be used to override the URI used at HttpProducer.

Assuming we have a route like
{code:java}
from("jetty:http://localhost/input?matchOnUriPrefix=true").to("http://localhost:/output");
{code}

When someone sends a POST to {{http://localhost/input/some/path}} the payload should be sent to {{http://localhost/output}} not to {{http://localhost/output/some/path}}

> Mixing jetty/http in a route screws up the URI used by HttpClient
> -----------------------------------------------------------------
>
>                 Key: CAMEL-2510
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2510
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.2.0
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3.0
>
>
> Below test shows the Http producer can't build up right HttpRequest URI as a bridgeEndpoint.
> {code}
>    public class JettyHttpTest extends CamelTestSupport {
>     private String targetProducerUri = "http://localhost:8542/someservice?bridgeEndpoint=true&throwExceptionOnFailure=false";
>     private String targetConsumerUri = "jetty:http://localhost:8542/someservice?matchOnUriPrefix=true";
>     private String sourceUri = "jetty:http://localhost:6323/myservice?matchOnUriPrefix=true";
>     private String sourceProducerUri = "http://localhost:6323/myservice";
>     @Test
>     public void testGetRootPath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice");
>         template.sendBody("direct:root", "");
>         assertMockEndpointsSatisfied();
>     }
>     
>     @Test
>     public void testGetWithRelativePath() throws Exception {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedBodiesReceived("Hi! /someservice/relative");
>         
>         template.sendBody("direct:relative", "");
>         assertMockEndpointsSatisfied();
>         
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from(targetConsumerUri)
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws Exception {
>                             String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
>                             exchange.getOut().setBody("Hi! " + path);
>                         }   
>                     });
>                 from(sourceUri)
>                     .to(targetProducerUri);
>                 from("direct:root")
>                     .to(sourceProducerUri)
>                     .to("mock:result");
>                 
>                 from("direct:relative")
>                     .to(sourceProducerUri + "/relative")
>                     .to("mock:result");
>             }
>         };
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.