[IPhone] Update LazyTableImages sample to cope with http compression

Apple recently enabled gzip compression on the rss feed which the normal
webclient class does not cope with.
This commit is contained in:
Alan McGovern 2011-10-06 13:53:31 +01:00
Родитель 3a85864637
Коммит 3c7a4c5720
3 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -79,7 +79,7 @@ namespace LazyTableImages {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
// Retrieve the rss feed from the server
var downloader = new WebClient ();
var downloader = new GzipWebClient ();
downloader.DownloadStringCompleted += DownloadCompleted;
downloader.DownloadStringAsync (RssFeedUrl);
}

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using System.Net;
namespace LazyTableImages
{
public class GzipWebClient : WebClient
{
protected override WebRequest GetWebRequest (Uri address)
{
var request = base.GetWebRequest (address);
if (request is HttpWebRequest)
((HttpWebRequest) request).AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
return request;
}
}
}

Просмотреть файл

@ -73,6 +73,7 @@
</Compile>
<Compile Include="App.cs" />
<Compile Include="RssParser.cs" />
<Compile Include="GzipWebClient.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="RootViewController.xib" />