Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Net;
- using System.Net.Cache;
- using System;
- namespace SharpGIS
- {
- /// <summary>
- /// A more efficient WebClient for .NET.
- /// Automatically uses GZIP/Deflate if the server supports it
- /// and caches responses if the server response contains a cache-
- /// header (ie. 'expires' or 'ETag').
- /// </summary>
- public class GZipWebClient : WebClient
- {
- public GZipWebClient()
- {
- //Use the browser cache if the server tells us the response is cacheable
- CachePolicy = new RequestCachePolicy(RequestCacheLevel.Default);
- }
- protected override System.Net.WebRequest GetWebRequest(Uri address)
- {
- System.Net.WebRequest wr = base.GetWebRequest(address);
- //Support GZIP and Deflate compressed responses from server
- ((HttpWebRequest)wr).AutomaticDecompression =
- DecompressionMethods.GZip | DecompressionMethods.Deflate;
- return wr;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment