Fix the check for version and PublicKeyToken
[mono.git] / mcs / class / Mono.Http / samples / http-get-gzip.cs
1 //
2 // http-get-gzip.cs: sample usage of GZipWebRequest
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (c) 2003 Ximian, Inc (http://www.ximian.com)
8 //
9 using System;
10 using System.IO;
11 using System.Net;
12 using System.Text;
13
14 using Mono.Http;
15
16 class GZipTest
17 {
18         static void GZWR (string url)
19         {
20                 WebRequest req = WebRequest.Create ("gziphttp://" + url);
21                 WebResponse wr = req.GetResponse ();
22                 Stream st = wr.GetResponseStream ();
23                 byte [] b = new byte [4096];
24                 long total = 0;
25                 int count;
26                 while ((count = st.Read (b, 0, 4096)) != 0) {
27                         Console.Write (Encoding.Default.GetString (b, 0, count));
28                         total += count;
29                 }
30
31                 st.Close ();
32
33                 Console.WriteLine ("\nContent-Encoding: '{0}' (if empty, not compressed)",
34                                     wr.Headers ["Content-Encoding"]);
35         }
36         
37         static void Main (string [] args)
38         {
39                 if (args.Length != 1) {
40                         Console.WriteLine ("You should provide a HTTP URL without 'http://'");
41                         return;
42                 }
43
44                 GZWR (args [0]);
45         }
46 }
47
48