RE: Re: How to write an Universal redirector
Hi, I've entered a new RFE for this point : http://restlet.tigris.org/issues/show_bug.cgi?id=1077 This is due to the request generated by the redirector. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2523593
RE: Re: How to write an Universal redirector
Hello ab, I'm sorry for the delay of my answer... I've juste tried with your sample project and was able to notice what looks like a bug with the internal client. When using the net extension, the application works perfectly on Tomcat. I investigate on this point and keep you informed. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2508920
RE: How to write an Universal redirector
Hi Tal, For now, I've moved up the variables table at the top of Resolver's Javadocs. I agree we should expose this feature even more in examples, etc. I've got some ideas for Restlet 2.1 on this front. Best regards, Jerome Louvel -- Restlet ~ Founder and Technical Lead ~ http://www.restlet.org Noelios Technologies ~ http://www.noelios.com -Message d'origine- De : Tal Liron [mailto:tal.li...@threecrickets.com] Envoyé : vendredi 26 février 2010 19:31 À : discuss@restlet.tigris.org Objet : Re: How to write an Universal redirector Hi Thierry -- The documentation for the URI template variables is so deeply hidden (Resolver API doc) that I always have trouble finding it. My recommendation is to put it somewhere much more obvious, possibly even in the first Resource tutorials, and to document it more with examples. It's such a powerful feature of Restlet! -Tal On 02/24/2010 02:32 AM, Thierry Boileau wrote: Hello, actually, the second parameter in the Redirector constructor is a template using a set of known variables (see [0]). You should be able to use the shipped Redirector, as follow (or something similar) new Redirector(getContext(), http://192.168.100.1:8080/RESTfulServices{rr};, Redirector.MODE_CLIENT_DISPATCHER)); Don't forget to declare the client HTTP connector on the component (such redirection is seen as a new client call issued by the Component). This is done in the web.xml file see ([1]) servlet [...] init-param param-nameorg.restlet.clients/param-name param-valueHTTP/param-value /init-param [...] /servlet [0] http://www.restlet.org/documentation/2.0/jse/api/org/restlet/util/Resolver.h tml [1] http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/Ser verServlet.html Best regards, Thierry Boileau Hello everybody, Could please anyone help me to write a universal redirector to match all requests and to redirected them to a remote host? Example: Start: /redirect/RESTfulServices/resources/customers/pkey/2176172632 Finish:http://192.168.100.1:8080/RESTfulServices/resources/customers/pkey/21 76172632 GWT Client side: ClientResource r = new ClientResource(/redirect/RESTfulServices/resources/customers/pkey/217617263 2); Server side class TestRestletApplication extends Application (my web.xml was changed to forward all /redirect/* requests to TestRestletApplication) Router router = new Router(getContext()); router.attach(/RESTfulServices, new MyRedirector(getContext(), null)); //-- this is wrong and MyRedirector class: public class MyRedirector extends Redirector { public MyRedirector(Context context, String targetTemplate) { // By default, the mode is MODE_CLIENT_DISPATCHER super(context, targetTemplate); } @Override protected Reference getTargetRef(Request request, Response response) { Reference ref = request.getResourceRef(); ref.setHostDomain(192.168.100.1); ref.setHostPort(8080); //-- here is missing something return ref; } } Thank you for helping me. ab View this message in context: How to write an Universal redirector http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4620578 .html Sent from the Restlet Discuss mailing list archive http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=24526 68 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2456943
Re: How to write an Universal redirector
Hello ab, thanks for your report, the bug has been fixed in the svn repository. Best regards, Thierry Boileau Hi, first, the good news: After downloading the current snapshot, I was able to make redirects... Thanx for fixing. Now the bad news: it is still not stable enough: My Redirector looks like this: *router.attach(/go/{host}/{port}/, new Redirector(getContext(), http://{host}:{port}/{rr};, Redirector.MODE_SERVER_OUTBOUND));* A call to http://localhost:/redirect/go/localhost/8080/RESTfulServices... forwards my request to http://localhost:8080/RESTfulServices... and it works fine... When I try to forward to a non-existing host (http://localhost:/redirect/go/WrongHostName/8080/RESTfulServices...) Restlet throws the following Java exception and any further requests are not possible any more. I have to restart the server...: 04.03.2010 11:39:48 org.restlet.routing.Redirector handle INFO: Redirecting via client dispatcher to: http://WrongHostName:8080/RESTfulServices/resources/customers/pkey/2176172632 04.03.2010 11:39:55 org.restlet.engine.log.LoggingThreadFactory$LoggingExceptionHandler uncaughtException SCHWERWIEGEND: Thread: Restlet-22593188 terminated with exception: null java.lang.NullPointerException at org.restlet.engine.http.connector.BaseClientHelper.handleOutbound(BaseClientHelper.java:555) at org.restlet.engine.http.connector.ControllerTask$4.run(ControllerTask.java:139) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Another problem is when I deploy the application to Tomcat. The Redirects do not work at all. Best Regards, ab View this message in context: Re: How to write an Universal redirector http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4673751.html Sent from the Restlet Discuss mailing list archive http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2454946
Re: How to write an Universal redirector
Hi ab, I mean the NPE has been fixed. I'll have a look at Tomcat later. Best regards, Thierry Boileau Hello ab, thanks for your report, the bug has been fixed in the svn repository. Best regards, Thierry Boileau Hi, first, the good news: After downloading the current snapshot, I was able to make redirects... Thanx for fixing. Now the bad news: it is still not stable enough: My Redirector looks like this: *router.attach(/go/{host}/{port}/, new Redirector(getContext(), http://{host}:{port}/{rr};, Redirector.MODE_SERVER_OUTBOUND));* A call to http://localhost:/redirect/go/localhost/8080/RESTfulServices... forwards my request to http://localhost:8080/RESTfulServices... and it works fine... When I try to forward to a non-existing host (http://localhost:/redirect/go/WrongHostName/8080/RESTfulServices...) Restlet throws the following Java exception and any further requests are not possible any more. I have to restart the server...: 04.03.2010 11:39:48 org.restlet.routing.Redirector handle INFO: Redirecting via client dispatcher to:http://WrongHostName:8080/RESTfulServices/resources/customers/pkey/2176172632 04.03.2010 11:39:55 org.restlet.engine.log.LoggingThreadFactory$LoggingExceptionHandler uncaughtException SCHWERWIEGEND: Thread: Restlet-22593188 terminated with exception: null java.lang.NullPointerException at org.restlet.engine.http.connector.BaseClientHelper.handleOutbound(BaseClientHelper.java:555) at org.restlet.engine.http.connector.ControllerTask$4.run(ControllerTask.java:139) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Another problem is when I deploy the application to Tomcat. The Redirects do not work at all. Best Regards, ab View this message in context: Re: How to write an Universal redirector http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4673751.html Sent from the Restlet Discuss mailing list archive http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2454947
Re: How to write an Universal redirector
Hi ab, Another problem is when I deploy the application to Tomcat. The Redirects do not work at all. what do you mean? Do you declare the required client connectors in the web.xml file (see the javadocs of the servlet adapter [0])? servlet [...] !-- List of supported client protocols (Optional - Only in mode 3) -- init-param param-nameorg.restlet.clients/param-name param-valueHTTP/param-value /init-param [...] /servlet Best regards, Thierry boileau [0] http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html Hi, first, the good news: After downloading the current snapshot, I was able to make redirects... Thanx for fixing. Now the bad news: it is still not stable enough: My Redirector looks like this: *router.attach(/go/{host}/{port}/, new Redirector(getContext(), http://{host}:{port}/{rr};, Redirector.MODE_SERVER_OUTBOUND));* A call to http://localhost:/redirect/go/localhost/8080/RESTfulServices... forwards my request to http://localhost:8080/RESTfulServices... and it works fine... When I try to forward to a non-existing host (http://localhost:/redirect/go/WrongHostName/8080/RESTfulServices...) Restlet throws the following Java exception and any further requests are not possible any more. I have to restart the server...: 04.03.2010 11:39:48 org.restlet.routing.Redirector handle INFO: Redirecting via client dispatcher to: http://WrongHostName:8080/RESTfulServices/resources/customers/pkey/2176172632 04.03.2010 11:39:55 org.restlet.engine.log.LoggingThreadFactory$LoggingExceptionHandler uncaughtException SCHWERWIEGEND: Thread: Restlet-22593188 terminated with exception: null java.lang.NullPointerException at org.restlet.engine.http.connector.BaseClientHelper.handleOutbound(BaseClientHelper.java:555) at org.restlet.engine.http.connector.ControllerTask$4.run(ControllerTask.java:139) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Another problem is when I deploy the application to Tomcat. The Redirects do not work at all. Best Regards, ab View this message in context: Re: How to write an Universal redirector http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4673751.html Sent from the Restlet Discuss mailing list archive http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2454949
Re: How to write an Universal redirector
Hello, thanks for providing a sample test case. I've just tried it with the last snapshot and it works well. Could you update your dependencies and test again? Best regards, Thierry Boileau Hi, It is really nice of you to help me. It is quite possible, that my problem is in the project set-up. The RestLet libraries are from 25.2.2010. I have minimized the Eclipse project to a single onModuleLoad function and the minimum of server-side classes (2). What it large makes are the libraries I useâEUR¦ You can see the project setup in the image file I have also attached. http://www.kybernetika.de/tmp/restlet/TestRestlet.zip http://www.kybernetika.de/tmp/restlet/TestRestlet.zip http://www.kybernetika.de/tmp/restlet/TestRestlet.gif http://www.kybernetika.de/tmp/restlet/TestRestlet.gif The best of all would be, if I could use on the client side something like this: ClientResource client = new ClientResource(âEURoehttp://weather.yahooapis.com/forecastrss?w=615702âEUR?); without having to implement ANY server side stuffâEUR¦ A BIG BIG thank you one more time! Have a nice weekend. ab jlouvel wrote: Hi ab, It would help if you could package a small project reproducing your issue. There is really nothing in Restlet that should prevent you from doing this reverse proxy scenario. Best regards, Jerome Louvel -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2453886
RE: How to write an Universal redirector
Hi ab, It would help if you could package a small project reproducing your issue. There is really nothing in Restlet that should prevent you from doing this reverse proxy scenario. Best regards, Jerome Louvel -- Restlet ~ Founder and Technical Lead ~ http://www.restlet.org Noelios Technologies ~ http://www.noelios.com -Message d'origine- De : asdfasdf [mailto:b...@duf.de] Envoyé : jeudi 25 février 2010 11:13 À : discuss@restlet.tigris.org Objet : Re: How to write an Universal redirector Hi, I have made some tests with Fiddler2. I have executed the same Request/Headers that I have posted above, and got a normal/JSON answer from my Tomcat running on 8080. The Question is: If the StdOut says Redirecting via client dispatcher to: http://localhost:8080/RESTful; who submits this Request? Browser, or Server? Please help me going... I am really stuck... Best wishes, ab -- View this message in context: http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4631601. html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=24519 91 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452520
RE: How to write an Universal redirector
Hi, It is really nice of you to help me. It is quite possible, that my problem is in the project set-up. The RestLet libraries are from 25.2.2010. I have minimized the Eclipse project to a single onModuleLoad function and the minimum of server-side classes (2). What it large makes are the libraries I use… You can see the project setup in the image file I have also attached. http://www.kybernetika.de/tmp/restlet/TestRestlet.zip http://www.kybernetika.de/tmp/restlet/TestRestlet.zip http://www.kybernetika.de/tmp/restlet/TestRestlet.gif http://www.kybernetika.de/tmp/restlet/TestRestlet.gif The best of all would be, if I could use on the client side something like this: ClientResource client = new ClientResource(“http://weather.yahooapis.com/forecastrss?w=615702”); without having to implement ANY server side stuff… A BIG BIG thank you one more time! Have a nice weekend. ab jlouvel wrote: Hi ab, It would help if you could package a small project reproducing your issue. There is really nothing in Restlet that should prevent you from doing this reverse proxy scenario. Best regards, Jerome Louvel -- View this message in context: http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4639743.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452580
Re: How to write an Universal redirector
Hi Thierry -- The documentation for the URI template variables is so deeply hidden (Resolver API doc) that I always have trouble finding it. My recommendation is to put it somewhere much more obvious, possibly even in the first Resource tutorials, and to document it more with examples. It's such a powerful feature of Restlet! -Tal On 02/24/2010 02:32 AM, Thierry Boileau wrote: Hello, actually, the second parameter in the Redirector constructor is a template using a set of known variables (see [0]). You should be able to use the shipped Redirector, as follow (or something similar) new Redirector(getContext(), http://192.168.100.1:8080/RESTfulServices{rr};, Redirector.MODE_CLIENT_DISPATCHER)); Don't forget to declare the client HTTP connector on the component (such redirection is seen as a new client call issued by the Component). This is done in the web.xml file see ([1]) servlet [...] init-param param-nameorg.restlet.clients/param-name param-valueHTTP/param-value /init-param [...] /servlet [0] http://www.restlet.org/documentation/2.0/jse/api/org/restlet/util/Resolver.html [1] http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html Best regards, Thierry Boileau Hello everybody, Could please anyone help me to write a universal redirector to match all requests and to redirected them to a remote host? Example: Start: /redirect/RESTfulServices/resources/customers/pkey/2176172632 Finish:http://192.168.100.1:8080/RESTfulServices/resources/customers/pkey/2176172632 GWT Client side: ClientResource r = new ClientResource(/redirect/RESTfulServices/resources/customers/pkey/2176172632); Server side class TestRestletApplication extends Application (my web.xml was changed to forward all /redirect/* requests to TestRestletApplication) Router router = new Router(getContext()); router.attach(/RESTfulServices, new MyRedirector(getContext(), null)); //-- this is wrong and MyRedirector class: public class MyRedirector extends Redirector { public MyRedirector(Context context, String targetTemplate) { // By default, the mode is MODE_CLIENT_DISPATCHER super(context, targetTemplate); } @Override protected Reference getTargetRef(Request request, Response response) { Reference ref = request.getResourceRef(); ref.setHostDomain(192.168.100.1); ref.setHostPort(8080); //-- here is missing something return ref; } } Thank you for helping me. ab View this message in context: How to write an Universal redirector http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4620578.html Sent from the Restlet Discuss mailing list archive http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452668
Re: How to write an Universal redirector
Hi, I have made some tests with Fiddler2. I have executed the same Request/Headers that I have posted above, and got a normal/JSON answer from my Tomcat running on 8080. The Question is: If the StdOut says Redirecting via client dispatcher to: http://localhost:8080/RESTful; who submits this Request? Browser, or Server? Please help me going... I am really stuck... Best wishes, ab -- View this message in context: http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4631601.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2451991
Re: How to write an Universal redirector
Hello, actually, the second parameter in the Redirector constructor is a template using a set of known variables (see [0]). You should be able to use the shipped Redirector, as follow (or something similar) new Redirector(getContext(), http://192.168.100.1:8080/RESTfulServices{rr};, Redirector.MODE_CLIENT_DISPATCHER)); Don't forget to declare the client HTTP connector on the component (such redirection is seen as a new client call issued by the Component). This is done in the web.xml file see ([1]) servlet [...] init-param param-nameorg.restlet.clients/param-name param-valueHTTP/param-value /init-param [...] /servlet [0] http://www.restlet.org/documentation/2.0/jse/api/org/restlet/util/Resolver.html [1] http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html Best regards, Thierry Boileau Hello everybody, Could please anyone help me to write a universal redirector to match all requests and to redirected them to a remote host? Example: Start: /redirect/RESTfulServices/resources/customers/pkey/2176172632 Finish: http://192.168.100.1:8080/RESTfulServices/resources/customers/pkey/2176172632 GWT Client side: ClientResource r = new ClientResource(/redirect/RESTfulServices/resources/customers/pkey/2176172632); Server side class TestRestletApplication extends Application (my web.xml was changed to forward all /redirect/* requests to TestRestletApplication) Router router = new Router(getContext()); router.attach(/RESTfulServices, new MyRedirector(getContext(), null)); //-- this is wrong and MyRedirector class: public class MyRedirector extends Redirector { public MyRedirector(Context context, String targetTemplate) { // By default, the mode is MODE_CLIENT_DISPATCHER super(context, targetTemplate); } @Override protected Reference getTargetRef(Request request, Response response) { Reference ref = request.getResourceRef(); ref.setHostDomain(192.168.100.1); ref.setHostPort(8080); //-- here is missing something return ref; } } Thank you for helping me. ab View this message in context: How to write an Universal redirector http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4620578.html Sent from the Restlet Discuss mailing list archive http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2451393
Re: How to write an Universal redirector
Hallo Thierry, After I have changed the mode to Redirector.MODE_SERVER_DISPATCHER my createInboundRoot method looks like this: @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_STARTS_WITH); router.attach(/RESTfulServices, new Redirector(getContext(), http://localhost:8080/RESTfulServices{rr};, Redirector.MODE_SERVER_DISPATCHER)); return router; } but I still receive no answer. My std output looks like this: 24.02.2010 10:51:00 org.restlet.engine.http.connector.HttpClientHelper start INFO: Starting the default HTTP client 24.02.2010 10:51:00 org.restlet.routing.Redirector handle INFO: Redirecting via server dispatcher to: http://localhost:8080/RESTfulServices/resources/customers/pkey/2176172632 24.02.2010 10:51:00 org.restlet.engine.log.LogFilter afterHandle INFO: 2010-02-2410:51:00127.0.0.1 - 127.0.0.1 GET /RESTfulServices/resources/customers/pkey/2176172632- 404 363 - 16 http://127.0.0.1: Restlet-Framework/2.0snapshot http://127.0.0.1:/testrestlet/hosted.html?testrestlet [WARN] 404 - GET /redirect/RESTfulServices/resources/customers/pkey/2176172632 (127.0.0.1) 363 bytes Request headers Host: 127.0.0.1: User-Agent: Restlet-Framework/2.0snapshot Accept: */* Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: http://127.0.0.1:/testrestlet/hosted.html?testrestlet Response headers Content-Type: text/html; charset=ISO-8859-1 Date: Wed, 24 Feb 2010 09:51:00 GMT Accept-Ranges: bytes Server: Restlet-Framework/2.0m7 Content-Length: 363 and my Firefox shows 404 with message The server has not found anything matching the request URI. May be this will help you helping me ;) Thank you again, ab -- View this message in context: http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4624772.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2451439
Re: How to write an Universal redirector
Hi Thierry, thank you for your help. It seems, that the redirection works now, but in my GWT application I can not see any correct answer. Firefox/Firebug sais: Request header: GET /redirect/RESTfulServices/resources/customers/pkey/2176172632 HTTP/1.1 Host: 127.0.0.1: User-Agent: Restlet-Framework/2.0snapshot Accept: */* Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: http://127.0.0.1:/testrestlet/hosted.html?testrestlet Answer header: HTTP/1.1 400 Bad Request Content-Location: http://localhost:8080/RESTfulServices/resources/customers/pkey/2176172632 Date: Wed, 24 Feb 2010 09:10:34 GMT Accept-Ranges: bytes Server: Apache-Coyote/1.1 Transfer-Encoding: chunked When I open the http://localhost:8080/RESTfulServices/resources/customers/pkey/2176172632 in a separate Firefox window, a correct answer is returned... (Is it because of the same origin policy?) It seems that this URL is called from the browser and not tunneled through the server... Thanks, ab -- View this message in context: http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4624601.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2451418
Re: How to write an Universal redirector
Guten Tag ab, you should keep the MODE_CLIENT_DISPATCHER mode. Could you trace the sent requests/response with wireshark, for example? Or let netcat listen on the 8080 (instead of your real server) port as follow : $nc -l -p 8080 It will show you the request that arrives from the server listening on port . Best regards, Thierry Boileau Hallo Thierry, After I have changed the mode to Redirector.*MODE_SERVER_DISPATCHER* my createInboundRoot method looks like this: @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_STARTS_WITH); router.attach(/RESTfulServices, new Redirector(getContext(), http://localhost:8080/RESTfulServices{rr};, Redirector.MODE_SERVER_DISPATCHER)); return router; } but I still receive no answer. My std output looks like this: 24.02.2010 10:51:00 org.restlet.engine.http.connector.HttpClientHelper start INFO: Starting the default HTTP client 24.02.2010 10:51:00 org.restlet.routing.Redirector handle INFO: Redirecting via server dispatcher to: http://localhost:8080/RESTfulServices/resources/customers/pkey/2176172632 24.02.2010 10:51:00 org.restlet.engine.log.LogFilter afterHandle INFO: 2010-02-24 10:51:00127.0.0.1 - 127.0.0.1 GET /RESTfulServices/resources/customers/pkey/2176172632- 404 363 - 16 http://127.0.0.1: Restlet-Framework/2.0snapshot http://127.0.0.1:/testrestlet/hosted.html?testrestlet [WARN] 404 - GET /redirect/RESTfulServices/resources/customers/pkey/2176172632 (127.0.0.1) 363 bytes Request headers Host: 127.0.0.1: User-Agent: Restlet-Framework/2.0snapshot Accept: */* Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: http://127.0.0.1:/testrestlet/hosted.html?testrestlet Response headers Content-Type: text/html; charset=ISO-8859-1 Date: Wed, 24 Feb 2010 09:51:00 GMT Accept-Ranges: bytes Server: Restlet-Framework/2.0m7 Content-Length: 363 and my Firefox shows 404 with message The server has not found anything matching the request URI. May be this will help you helping me ;) Thank you again, ab View this message in context: Re: How to write an Universal redirector http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4624772.html Sent from the Restlet Discuss mailing list archive http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2451468
Re: How to write an Universal redirector
Hi Thierry, With WireShark I am not able to listen on the localhost communication but here is the NetCat output: D:\Programme\NCatncat -l -p 8080 GET /RESTfulServices/resources/customers/pkey/2176172632 HTTP/1.1 Transfer-Encoding: chunked Date: Wed, 24 Feb 2010 13:19:10 GMT Accept: */* Accept-Charset: ISO-8859-1, UTF-8;q=0.7, *;q=0.7 Accept-Encoding: gzip, deflate Accept-Language: de-de, de;q=0.8, en-us;q=0.5, en;q=0.3 Referer: http://127.0.0.1:/testrestlet/hosted.html?testrestlet User-Agent: Restlet-Framework/2.0snapshot Cookie: http%3A%2F%2F127.0.0.1%3A%2Feintragspflege%2Ftheme=%7B%22state%22%3A%7B%22id%22%3A%22s%3Ablue%22%2C%20%22file%22%3A%22s%3Agxt-all.css%22%7D%7D 0 ^C D:\Programme\NCat I have set up my RESTfulServices on another machine and I can send you the WireShark communication if it might help… Gruß, Cheers, ab Thierry Boileau wrote: Guten Tag ab, you should keep the MODE_CLIENT_DISPATCHER mode. Could you trace the sent requests/response with wireshark, for example? Or let netcat listen on the 8080 (instead of your real server) port as follow : $nc -l -p 8080 It will show you the request that arrives from the server listening on port . Best regards, Thierry Boileau -- View this message in context: http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4625967.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2451547
How to write an Universal redirector
Hello everybody, Could please anyone help me to write a universal redirector to match all requests and to redirected them to a remote host? Example: Start: /redirect/RESTfulServices/resources/customers/pkey/2176172632 Finish: http://192.168.100.1:8080/RESTfulServices/resources/customers/pkey/2176172632 GWT Client side: ClientResource r = new ClientResource(/redirect/RESTfulServices/resources/customers/pkey/2176172632); Server side class TestRestletApplication extends Application (my web.xml was changed to forward all /redirect/* requests to TestRestletApplication) Router router = new Router(getContext()); router.attach(/RESTfulServices, new MyRedirector(getContext(), null)); // -- this is wrong and MyRedirector class: public class MyRedirector extends Redirector { public MyRedirector(Context context, String targetTemplate) { // By default, the mode is MODE_CLIENT_DISPATCHER super(context, targetTemplate); } @Override protected Reference getTargetRef(Request request, Response response) { Reference ref = request.getResourceRef(); ref.setHostDomain(192.168.100.1); ref.setHostPort(8080); // -- here is missing something return ref; } } Thank you for helping me. ab -- View this message in context: http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4620578.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2451106