Repository: camel Updated Branches: refs/heads/master 83f909bfa -> c44c0b0d8
Changes to allow spaces in restlet URLs Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c44c0b0d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c44c0b0d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c44c0b0d Branch: refs/heads/master Commit: c44c0b0d8f0106e916a28be54c1c943cbaca56d9 Parents: 83f909b Author: jmandawg <jmand...@hotmail.com> Authored: Tue May 17 20:41:13 2016 -0400 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon May 23 09:00:04 2016 +0200 ---------------------------------------------------------------------- .../component/restlet/RestletComponent.java | 7 ++++--- .../restlet/RestletRouteBuilderTest.java | 22 +++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/c44c0b0d/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java index 8ba21f5..409c667 100644 --- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java +++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java @@ -104,7 +104,8 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements R @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - RestletEndpoint result = new RestletEndpoint(this, remaining); + String remainingRaw = URISupport.extractRemainderPath(new URI(uri), true); + RestletEndpoint result = new RestletEndpoint(this, remainingRaw); if (synchronous != null) { result.setSynchronous(synchronous); } @@ -115,10 +116,10 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements R result.updateEndpointUri(); // construct URI so we can use it to get the splitted information - URI u = new URI(remaining); + URI u = new URI(remainingRaw); String protocol = u.getScheme(); - String uriPattern = u.getPath(); + String uriPattern = u.getRawPath(); if (parameters.size() > 0) { uriPattern = uriPattern + "?" + URISupport.createQueryString(parameters); } http://git-wip-us.apache.org/repos/asf/camel/blob/c44c0b0d/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java ---------------------------------------------------------------------- diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java index 7509f68..229be75 100644 --- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java +++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java @@ -78,7 +78,7 @@ public class RestletRouteBuilderTest extends RestletTestSupport { + exchange.getIn().getHeader("x")); } }); - + // Restlet consumer to handler FORM POST method from("restlet:http://localhost:" + portNum + "/login?restletMethod=post").process(new Processor() { public void process(Exchange exchange) throws Exception { @@ -89,6 +89,17 @@ public class RestletRouteBuilderTest extends RestletTestSupport { + exchange.getIn().getHeader("passwd")); } }); + + // Restlet consumer default to handle GET method + from("restlet:http://localhost:" + portNum + "/orders with spaces in path/{id}/{x}").process(new Processor() { + public void process(Exchange exchange) throws Exception { + exchange.getOut().setBody( + "received GET request with id=" + + exchange.getIn().getHeader("id") + + " and x=" + + exchange.getIn().getHeader("x")); + } + }); } }; } @@ -142,6 +153,15 @@ public class RestletRouteBuilderTest extends RestletTestSupport { } @Test + public void testConsumerWithSpaces() throws IOException { + Client client = new Client(Protocol.HTTP); + Response response = client.handle(new Request(Method.GET, + "http://localhost:" + portNum + "/orders with spaces in path/99991/6")); + assertEquals("received GET request with id=99991 and x=6", + response.getEntity().getText()); + } + + @Test public void testUnhandledConsumer() throws IOException { Client client = new Client(Protocol.HTTP); Response response = client.handle(new Request(Method.POST,