зеркало из https://github.com/xamarin/ios-samples.git
[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:
Родитель
3a85864637
Коммит
3c7a4c5720
|
@ -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" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче