Hi billy,

As I've made my tests with web browsers, I've just noticed that the the "\" characters are - percent-encoded automatically by firefox (e.g. http://localhost/path/c:%5C%5Ctemp/afile/abdc.txt) - and converted as follow by IE7 http://localhost/path/c://temp/afile/abdc.txt

The uri provided by firrefox is ok, but the one "generated" by IE does not work (also in Firefox).
But there is a way to fix it :

Route route = router.attach("/sid/{sid}/afile/{filename}", AFileResource.class);
Variable variable = new Variable(Variable.TYPE_ALL);
template.getVariables().put("path", variable);

The reason is that by default, variables catch "segments", ie something between "/" characters.

I hope it will help you.
Best regards,
Thierry Boileau
Hi Thierry,

This is a follow up post to "How to send files using Restlet" that first appeared on July 5, 07. I posted it here in case it goes without being noticed.

But in escaped URLs, escaped slashs and backslahs are still slashs and backslahs. If my parameters consist of Windows or Unix path separators, there will be problems,

e.g.,
Application:
router.attach("/path/{path}/afile/{filename}", AFileResource.class);
AFileResource:
this.systemId = (String) request.getAttributes().get("path");

So when the client calls with the link below,
on Unix, it is: "/path//tmp/afile/abc.txt"
on Windows, it is: "/path/c:\\temp/afile/abc.txt"

it will result in a 404 (not found) I am using restful web services chapter 7 as test. When the client call has been passed to Application and router object is created, the exception is thrown.

The code is as follows:


@Override
public Restlet createRoot() {
    Router router = new Router(getContext());

    // Add a route for user resources
    router.attach("/users/{username}", UserResource.class);

    // Add a route for user's bookmarks resources
    router.attach("/users/{username}/bookmarks", BookmarksResource.class);

    // Add a route for bookmark resources
    Route uriRoute = router.attach("/users/{username}/bookmarks/{URI}",
            BookmarkResource.class);
    uriRoute.getTemplate().getVariables().put("URI",
            new Variable(Variable.TYPE_URI_ALL));

    // Add a route for user resources
    /*
    router.attach("/afile", AFileResource.class);
    router.attach("/afile/{filename}", AFileResource.class);
    */
    router.attach("/sid/{sid}/afile", AFileResource.class);
    router.attach("/sid/{sid}/afile/{filename}", AFileResource.class);

    return router;
}

BTW, is there an easy way to tell apart the new follow posts to old topics without scrolling through all the pages?
thanks, billy




Reply via email to