restlet / restlet-framework-java

The first REST API framework for Java
https://restlet.talend.com
Other
654 stars 284 forks source link

Deflate encoding broken for Internet Explorer #654

Open tliron opened 12 years ago

tliron commented 12 years ago

Currently, if Deflate is negotiated as the preferred encoding, the representation will not be unpacked by Internet Explorer. This is a severe bug!

This is due to Restlet using the wrong kind of Deflate encoding:

https://github.com/restlet/restlet-framework-java/issues/653

The solution suggested by Jerome is for TunnelService to prefer Encoding.DEFLATE_NOWRAP when detecting Internet Explorer:

http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3005411

tliron commented 11 years ago

I'm unclear how to fix this. There doesn't seem to be any code in TunnelService addressing IE.

thboileau commented 11 years ago

Ok, I have a look.

thboileau commented 11 years ago

Hi Tal, I've added the ability to override the accept-encoding header. It is based on the tunnel service (turn the userAgentTunnel proprty to "true"). By default, it will replace the "accept-encoding" header value for msie, only if its curent value is "deflate", have a look at the modules/org.restlet/src/org/restlet/service/accept-encoding.properties. I think you will understand it quickly. If not, please tell me. By the way, you can also tell me what could the default value for the msie browser. Cheers.

tliron commented 11 years ago

Thierry, the truth is that all non-IE browsers will be able to accept both kinds of DEFLATE, so one solution is to simply default to DEFLATE_NOWRAP (RFC 1951). However, I know Restlet generally prefers to follow the specs closely, and in that case actually DEFLATE (RFC 1950) should be preferred if it's not IE.

The problem with IE was apparent in versions 6 to 8, but I couldn't find information about newer versions. It seems that a very common configuration for web servers and frontend caches is to filter Internet Explorer by "MSIE" in the agent string, though that doesn't include the version. But, I personally don't see any big harm in always using DEFLATE_NOWRAP with IE, whatever the version.

Some relevant reading I found:

http://stackoverflow.com/a/2541174/849021 http://en.wikipedia.org/wiki/Gzip

tliron commented 10 years ago

I hope this issue won't remain unfixed for 2.2! It's a very long-running problem with Restlet and IE support: it means DEFLATE has to be disabled if IE support is needed. If you like, we can set an online chat sometime and discuss together the best solution.