You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jay mann (JIRA)" <ji...@apache.org> on 2016/03/02 14:37:18 UTC

[jira] [Comment Edited] (CAMEL-9651) Restlet consumer request fails if there is a space '%20' in the url

    [ https://issues.apache.org/jira/browse/CAMEL-9651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15175593#comment-15175593 ] 

Jay mann edited comment on CAMEL-9651 at 3/2/16 1:37 PM:
---------------------------------------------------------

I've attached a simple patch to use rawURL for the uriPattern and endpointURI ONLY.  This way restlet can match the uri correctly for consumer, and new URI() does not fail for producers.

Simple test to show consumer & producer both work with spaces in url.  Browse to http://localhost:9999/test%20me/now/:

{code}
from("restlet:http://localhost:9999/test me/now").process(new Processor() {
	@Override
	public void process(Exchange exchange) throws Exception {
                System.out.println("Hi There" + exchange.getIn().getHeader(Exchange.HTTP_QUERY));
			}
		}).choice()
         	.when(header(Exchange.HTTP_QUERY).isNull())
         		.to("restlet:http://localhost:9999/test me/now?val=1")
         	.otherwise()
             	.setHeader("Content-Type", constant("application/json"))
         		.setBody(simple("{\"DONE\": \"${header.CamelHttpQuery}\"}"))
     		.endChoice();

{code}


was (Author: jmandawg):
patch to use rawURL for the uriPattern and endpointURI only.

Simple test to show consumer & producer both work with spaces in url.  Browse to http://localhost:9999/test%20me/now/:

{code}
from("restlet:http://localhost:9999/test me/now").process(new Processor() {
	@Override
	public void process(Exchange exchange) throws Exception {
                System.out.println("Hi There" + exchange.getIn().getHeader(Exchange.HTTP_QUERY));
			}
		}).choice()
         	.when(header(Exchange.HTTP_QUERY).isNull())
         		.to("restlet:http://localhost:9999/test me/now?val=1")
         	.otherwise()
             	.setHeader("Content-Type", constant("application/json"))
         		.setBody(simple("{\"DONE\": \"${header.CamelHttpQuery}\"}"))
     		.endChoice();

{code}

> Restlet consumer request fails if there is a space '%20' in the url
> -------------------------------------------------------------------
>
>                 Key: CAMEL-9651
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9651
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-restlet
>    Affects Versions: 2.16.2
>            Reporter: Jay mann
>         Attachments: patch.txt
>
>
> Consuming a restful service using restlet component fails with URISyntaxException if there is a special character or space in the URL.  
> To fix this org.apache.camel.component.restlet.RestletComponent should:
> {code}
> @Override
>     public boolean useRawUri() {
>         // should use encoded uri by default
>         return true;
>     }
> {code}
> Simple example of failure:
> {code}
>  rest("/Utils")
> 	    	.description("Camel Utilities Rest Service")
> 	    	.consumes("application/json").produces("application/json")
> 	    	.get("test/testme").route().log("Got HEre").
>                 to("restlet:http://localhost:8299/Utils/test2/TEST%20Name?throwExceptionOnFailure=false&restletMethod=GET")
>                 .getRestDefinition()
>             .get("test2/{name2}").route().log("GOt ${header.name2}");
> {code}
> If you remove the space it works fine.
> {code}
> Caused by: java.net.URISyntaxException: Illegal character in path at index 38: http://localhost:8299/Utils/test2/TEST Name
> 	at java.net.URI$Parser.fail(URI.java:2848)
> 	at java.net.URI$Parser.checkChars(URI.java:3021)
> 	at java.net.URI$Parser.parseHierarchical(URI.java:3105)
> 	at java.net.URI$Parser.parse(URI.java:3053)
> 	at java.net.URI.<init>(URI.java:588)
> 	at org.apache.camel.component.restlet.RestletComponent.createEndpoint(RestletComponent.java:120)
> 	at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:114)
> 	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:570)
> {code}
> It seems like there are lots of bugs with restlet component, What is the most mature service for consuming restful/http services?
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)