public static String asURL(String uri) {
        try {
            new URL(uri);
            return uri;
        } catch (Exception e) {}
        Request req = Request.getCurrent();
        if (req == null) return uri;
        Map<String, Object> attrs = req.getAttributes();
        Series<?> series = (Series<?>) attrs.get("org.restlet.http.headers");
        String realURI = series.getFirstValue("X-Real-URI");
        if (realURI != null) return realURI.concat(uri);
        String root = req.getRootRef().toString();
        return root.concat(uri);
    }