<?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>Marcus Povey &#187; internet explorer</title>
	<atom:link href="http://www.marcus-povey.co.uk/tag/internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcus-povey.co.uk</link>
	<description>Making the world a better place, one byte at a time...</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:13:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<atom:link rel='hub' href='http://www.marcus-povey.co.uk/?pushpress=hub'/>
		<item>
		<title>Corrupted downloads via script on IE</title>
		<link>http://www.marcus-povey.co.uk/2009/01/05/corrupted-downloads-via-script-on-ie/</link>
		<comments>http://www.marcus-povey.co.uk/2009/01/05/corrupted-downloads-via-script-on-ie/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 14:58:17 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[corruption]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[mimetype]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=132</guid>
		<description><![CDATA[I have spent the last couple of hours grappling with this problem, and having finally got to the bottom of it I&#8217;d thought I&#8217;d share my solution. Ok, so the problem was that a PHP script which prepared a download (in this case a .zip) from Elgg&#8217;s file store was working fine in Firefox but [...]]]></description>
			<content:encoded><![CDATA[<p>I have spent the last couple of hours grappling with this problem, and having finally got to the bottom of it I&#8217;d thought I&#8217;d share my solution.</p>
<p>Ok, so the problem was that a PHP script which prepared a download (in this case a .zip) from Elgg&#8217;s file store was working fine in Firefox but producing a corrupt archive in IE.</p>
<p>On examining the headers being sent and received I was able to establish that there were two main issues going on:</p>
<ol>
<li>The zip file was being compressed by mod_deflate, this was being incorrectly handled by Internet Explorer, and so was producing a file which was actually a gzipped .zip file. This is a known issue, and is why Elgg&#8217;s .htaccess file only compresses text and javascript.</li>
<li>The code which only permits compression for text mime types was being ignored.</li>
</ol>
<p>The reason, obvious with hindsight but not at the time, was this:</p>
<p>The file was being served by a script, this script modifies the mimetype via header. However, apache was determining whether to compress the file or not based on the <em>initial</em> mimetype of the script &#8211; which of course was text/html!</p>
<p>Once I figured that out, it was fairly simple to solve. I added the following lines to the mod_deflate settings in the .htaccess file.</p>
<blockquote><p><code>SetEnvIfNoCase Request_URI action\/* no-gzip dont-vary<br />
SetEnvIfNoCase Request_URI actions\/* no-gzip dont-vary</code></p></blockquote>
<p>These lines turn off gzip compression for all actions, while leaving compression running for all other files. This solution is better than turning compression off altogether but it is not ideal, for one if you attempt a script download from anywhere but an Elgg action (which really you shouldn&#8217;t be), you will need to modify .htaccess yourself.</p>
<p>Any better solutions welcome!</p>
<div class="wsbuttons">
	<div class="shareblob facebook">
		<div class="fb-like" data-href="http://www.marcus-povey.co.uk/2009/01/05/corrupted-downloads-via-script-on-ie/" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false" data-colorscheme="light"></div>
	</div>

	<div class="shareblob google">
		<div class="g-plusone" data-size="tall" data-href="http://www.marcus-povey.co.uk/2009/01/05/corrupted-downloads-via-script-on-ie/"></div>
	</div>

	<div class="shareblob twitter">
		<div class="twitter">
			<a href="https://twitter.com/share?url=http%3A%2F%2Fwww.marcus-povey.co.uk%2F2009%2F01%2F05%2Fcorrupted-downloads-via-script-on-ie%2F&count=vertical" class="twitter-share-button" data-lang="en">Tweet</a>
			<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
		</div>
	</div>

</div>
	]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2009/01/05/corrupted-downloads-via-script-on-ie/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

