<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Martín Verzilli &#187; Jetty</title>
	<atom:link href="http://weblogs.manas.com.ar/mverzilli/category/jetty/feed/" rel="self" type="application/rss+xml" />
	<link>http://weblogs.manas.com.ar/mverzilli</link>
	<description></description>
	<lastBuildDate>Wed, 19 May 2010 11:48:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Silverlight 2 RTM problem with Internet Explorer 6 and GZip compression: a workaround if you&#8217;re using Jetty</title>
		<link>http://weblogs.manas.com.ar/mverzilli/2008/11/04/silverlight-2-rtm-problem-with-internet-explorer-6-and-gzip-compression-a-workaround-if-youre-using-jetty/</link>
		<comments>http://weblogs.manas.com.ar/mverzilli/2008/11/04/silverlight-2-rtm-problem-with-internet-explorer-6-and-gzip-compression-a-workaround-if-youre-using-jetty/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 21:11:06 +0000</pubDate>
		<dc:creator>mverzilli</dc:creator>
				<category><![CDATA[GZip]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Jetty]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://weblogs.manas.com.ar/mverzilli/?p=10</guid>
		<description><![CDATA[We are developing a Silverlight application since some months ago. As you may know, an RTM of Silverlight 2 has been released recently, so we decided to migrate our project to it. Surprisingly, it stopped to work in IE 6 after the migration. The exception raised by Silverlight looked like: [BrowserHttpWebRequest_WebException_RemoteServer] Arguments:NotFound Debugging resource strings [...]]]></description>
			<content:encoded><![CDATA[<p>We are developing a Silverlight application since some months ago. As you may know, an RTM of Silverlight 2 has been released recently, so we decided to migrate our project to it. Surprisingly, it stopped to work in IE 6 after the migration. The exception raised by Silverlight looked like:</p>
<blockquote><p>[BrowserHttpWebRequest_WebException_RemoteServer]</p>
<p>Arguments:NotFound</p>
<p>Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See <a href="http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=2.0.31005.0&amp;File=System.Windows.dll&amp;Key=BrowserHttpWebRequest_WebException_RemoteServer">http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=2.0.31005.0&amp;File=System.Windows.dll&amp;Key=BrowserHttpWebRequest_WebException_RemoteServer</a></p></blockquote>
<p>Pretty mysterious, isn&#8217;t it? Well, fortunately I googled it, and I found the following thread in the official Silverlight forum:</p>
<p><a title="https://silverlight.net/forums/p/42908/123627.aspx" href="https://silverlight.net/forums/p/42908/123627.aspx">https://silverlight.net/forums/p/42908/123627.aspx</a></p>
<p>According to Vijay Devatha, from the Silverlight team:</p>
<blockquote><p>This is a known issue that, unfortunately, currently has no workaround. We definitely plan to fix it in the following release; but like I said, for the time being, to get this scenario to work in on IE6, you&#8217;re going to have to either disable compressing the content (on the server side), or have the server not set the Cache header to no-cache.</p></blockquote>
<p>I didn&#8217;t have the Cache-Control header field set to no-cache, so that wasn&#8217;t the problem. Then I tried disabling GZip compression and it worked!</p>
<p>Great but&#8230; GZip compression was there for a good reason. Having to disable it for Firefox, Safari and even IE7 just because it didn&#8217;t work with IE6 didn&#8217;t sound like a great deal&#8230; So the most reasonable workaround seemed to disable GZip just for IE6.</p>
<h3><span style="text-decoration: underline;">Using an exclusion list of user agents to disable GZip in Jetty for some browsers</span></h3>
<p>In the second part of this post, I&#8217;ll show how to disable GZip compression for a fixed list of browsers. It is simple, but I had to figure it out from scratch, because I didn&#8217;t find much documentation on the subject.</p>
<p>If you want to implement GZip in Jetty, you just have to add a GZipFilter to the filter chain of your Jetty context. Usually, this is done as follows:</p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">context.addFilter(GZipFilter.class, "/*", 0);</pre>
<p>Now, we want GZipFilter to be applied just when the request comes from some browsers. There&#8217;s an initialization parameter which allows us to do that: excludeUserAgents.</p>
<p>So the above code now will look as follows:</p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">GzipFilter gzipFilter = new GzipFilter();

FilterHolder filterHolder = new FilterHolder(gzipFilter);

filterHolder.setInitParameter("userAgent", "(?:Mozilla[^\\(]*\\(compatible;
    \\s*+([^;]*);.*)|(?:.*?([^\\s]+/[^\\s]+).*)");

filterHolder.setInitParameter("excludedAgents", "MSIE 6.0");

context.addFilter(filterHolder, "/*", 0);</pre>
<p>Since we need to customize some parameters from GzipFilter, we can&#8217;t let the Jetty Context instantiate it anymore.</p>
<p>There&#8217;s an overload of addFilter which expects a FilterHolder object instead of a Class. The FilterHolder will act as a proxy and will set up the GzipFilter instance for us when a request has to be satisfied.</p>
<p>So we inject the GzipFilter instance into the FilterHolder constructor and set up the custom parameters we need. The &#8220;userAgent&#8221; parameter is mandatory, it states which user agents will be processed. The regex I&#8217;m using should match any of the main browsers out there.</p>
<p>Now we just need to exclude the browsers we don&#8217;t want to receive gzipped content. This is done by setting the &#8220;excludedAgents&#8221; parameter. It expects a comma separated list of user agent ids. In my case, I just needed to filter out IE6, so I set &#8220;MSIE 6.0&#8243;</p>
<p>This way we can have our application working on IE6 while we wait for the problem to be fixed.</p>
<p>Martin</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogs.manas.com.ar/mverzilli/2008/11/04/silverlight-2-rtm-problem-with-internet-explorer-6-and-gzip-compression-a-workaround-if-youre-using-jetty/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
