Hi Bruno, Long delay for this one, sorry.
I don't know what is going on and would need to trace/reproduce. Were you able to solve the issue somehow? Otherwise, could you enter a bug report with ideally a your test resource. Best regards, Jerome -- Restlet ~ Founder and Technical Lead ~ http://www.restlet.org Noelios Technologies ~ http://www.noelios.com -----Message d'origine----- De : Bruno Harbulot [mailto:[email protected]] Envoyé : lundi 28 juin 2010 18:35 À : [email protected] Objet : Content-type negotiation and user-agent tunnel Hi, I'm trying to understand why Chrome and MSIE get a different content type via the tunnel than Opera, although the settings seem to be the same. I'm using 2.0-RC4, and accept.properties [1] seems to have the same settings for all the browsers. User-agent tunnelling is enabled in the application using this: getTunnelService().setUserAgentTunnel(true); The request is done via jQuery/Ajax and I set the request's content type with this: beforeSend: function(xhr) { xhr.setRequestHeader('Accept','application/json'); } Firefox sends 'Accept: application/json' whereas MSIE, Opera and Chrome send 'Accept: */*, application/json'. The Opera user agent header is: User-Agent: Opera/9.80 (X11; Linux x86_64; U; en-GB) Presto/2.5.24 Version/10.53 The Chrome user agent header is: User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4 The resource uses: @Post("form:html") postToHtml(Representation entity) { ... } @Post("form:json") postToJson(Representation entity) { ... } The content-negotiation seems to work fine in Firefox, Opera and MSIE, but the HTML variant is selected when it's Chrome. These commands returns a JSON representation (as expected): curl -v -d 'var=value' http://localhost:8182/ curl -v -d 'var=value' -H 'Accept: */*, application/json' -H 'User-Agent: Opera/9.80 (X11; Linux x86_64; U; en-GB) Presto/2.5.24 Version/10.53' http://localhost:8182/ This command returns an HTML representation (not as expected): curl -v -d 'var=value' -H 'Accept: */*, application/json' -H 'User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4' http://localhost:8182/ When I change accept.properties to contains this, it works: #Internet explorer agentName: msie acceptOld: */*, application/json acceptNew: */*, application/json agentName: msie acceptOld: acceptNew: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 #Opera agentName: opera acceptOld: acceptNew: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 #Safari agentName: safari acceptOld: acceptNew: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 #Chrome agentName: chrome acceptOld: */*, application/json acceptNew: */*, application/json agentName: chrome acceptOld: acceptNew: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 I'm confused regarding why Chrome and MSIE need this exception, whereas Opera doesn't. Any ideas? Best wishes, Bruno. [1] http://restlet.tigris.org/source/browse/restlet/trunk/modules/org.restlet/src/org/restlet/service/accept.properties ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2626970 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2657868

