On Wed, Feb 22, 2012 at 05:48, Thierry Boileau <thierry.boil...@noelios.com> wrote: > I've made some tests using Restlet 2.0 and 2.1. From what I notice, in this > case, the order is not significant. > I get the "xhtml" representation instead of the "html" one in both cases : > @Get(“html|xhtml”) and @Get(“xhtml|html”) > > Here is my explanation : "html" is a shortcut for "text/html" and "xhtml" > stands for "application/xhtml+xml". > When the client provides no preference, then the default one set on the > MetadataService is applied : by default "application/octet-stream". > The curent score algorithm gives a better affinity between > "application/xhtml+xml" and "application/octet-stream" than between > "text/html" and "application/octet-stream", because of "application/"... The > scores are very low : 0.0006 and 0.0003 but the difference is real. > > Good news anyway, you can set the default media type of the application's > MetadataService to a neutral one : "*/*" : > getMetadataService().setDefaultMediaType(MediaType.ALL); > > In this case, the order is significant, once again.
Thanks Thierry, this is very very helpful, I appreciate you looking into this. First: I suggest we make MediaType.ALL the default in 2.1 and 2.2. Second: I’ve made this change in my application, and it seemed to work at first — but it turns out that the behavior of my resource, when I don’t send an Accept header, has become unpredictable. I have these two methods in my resource class: @Get("html|xhtml") public Representation getHtml(Variant variant) and: @Get("json") public Representation getJson() now that I’ve made this change, most of the time when I run my app and make a request for this resource without the Accept header, I get back a response with the Content-Type being text/html, which is what I want and expect. However, sometimes when I start my app and make the request, I get back a JSON response. This is of course not acceptable; I need the behavior of my app to be predictable and consistent. Unfortunately I can’t give you statistics on how often this occurs; my app takes a long time to start up. Off the top of my head, it seems to be around 20% of the time. Can you suggest any theories for why this might be happening, and some possible ways to prevent this from happening? Thanks! Avi Avi Flax » Arc90 » http://arc90.com Kindling » Innovation through Collaboration » http://kindlingapp.com Readability » Enjoy Reading, Support Writing » http://readability.com ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2936716