I've used the following code successfully to proxy images. Overriding getTargetRef involves more code, but it also gives you direct control over the redirection. (This code works, but I'd love to hear from experts whether there is a better way. Also, I'm not sure, but I think it interacts badly with caching when Apache httpd is in front of it. Does that ring a bell?)
@Override public Restlet createInboundRoot() { Router router = new Router(getContext()); router.attachDefault(new Filter(getContext(), new Redirector(getContext(), "", MODE_SERVER_OUTBOUND) { @Override protected Reference getTargetRef(Request request, Response response) { String rr = request.getResourceRef().getRemainingPart(true); // Strip initial slash, if present. if (rr.startsWith("/")) { rr = rr.substring(1); } return new Reference(rr); } } ) { // We only redirect to URIs that look like images. @Override protected int beforeHandle(Request request, Response response) { String rr = request.getResourceRef().getRemainingPart(true); if (!IMG_PATTERN.matcher(rr).find()) { response.setStatus(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE, "Not an image type"); return Filter.STOP; } return Filter.CONTINUE; } }); return router; } --tim On Wed, Jul 25, 2012 at 9:02 AM, Laurens Rietveld < laurens.rietv...@gmail.com> wrote: > I'm currently dealing with the following scenario: I want to forward users > to > a different site using the Redirector class. The site to forward the user > to > is included in the url: e.g. > http://localhost/restlet/http://www.google.com?q=just-a-query. > > I'm not using TYPE_URI_ALL because I want to process the path and query > separately. I use the TYPE_URI_PATH and TYPE_URI_QUERY for this. Problem > is: > the url used above does not match this pattern. Below is the code I use. > I'm > clearly overlooking something, as this is not a strange scenario. Could > someone help me out? (ps. I use the 2.2-snapshot version) > > Router router = new Router(getContext()); > Redirector redirector = new Redirector(getContext(), "{uriPath}?{query}", > Redirector.MODE_CLIENT_FOUND); > TemplateRoute route = router.attach("/restlet/{uriPath}?{query}", > redirector); > Map<String, Variable> routeVariables = route.getTemplate().getVariables(); > routeVariables.put("uriPath", new Variable(Variable.TYPE_URI_PATH)); > routeVariables.put("query", new Variable(Variable.TYPE_URI_QUERY)); > > > > -- > View this message in context: > http://restlet-discuss.1400322.n2.nabble.com/Unable-to-retrieve-URI-query-and-path-from-link-tp7578244.html > Sent from the Restlet Discuss mailing list archive at Nabble.com. > > ------------------------------------------------------ > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2992932 > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2992947