ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/HostUpdateSharp/HostUpdateSharp.cs
(Generate patch)

Comparing HostUpdateSharp/HostUpdateSharp.cs (file contents):
Revision 93 by Douglas Thrift, 2004-03-01T23:37:27-08:00 vs.
Revision 98 by Douglas Thrift, 2004-03-02T01:17:58-08:00

# Line 8 | Line 8 | using System;
8   using System.IO;
9   using System.Net;
10   using System.Text;
11 + #if !_FreeBSD_
12 + using System.Windows.Forms;
13 + #endif
14  
15   public class HostUpdateSharp
16   {
17          public static void Main(string[] args)
18          {
19 +                foreach (string arg in args)
20 +                {
21 +                        switch (arg)
22 +                        {
23 +                        case "-D":
24 +                                debug = true;
25 +                                break;
26 +                        }
27 +                }
28 +
29                  try
30                  {
31                          new HostUpdateSharp();
# Line 29 | Line 42 | public class HostUpdateSharp
42                          host.Append(".local.douglasthrift.net");
43                  }
44  
45 <                CredentialCache cache = new CredentialCache();
45 >                WebHeaderCollection headers = new WebHeaderCollection();
46  
47 <                cache.Add(new Uri(url), "Basic", new NetworkCredential("HostUpdate",
48 <                        "frell2003"));
47 >                headers.Add("Authorization", "Basic " + Convert.ToBase64String((new
48 >                        ASCIIEncoding()).GetBytes("HostUpdate:frell2003")));
49  
50                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
51  
52                  request.Accept = "text/plain";
53                  request.ContentLength = host.Length;
54                  request.ContentType = "application/x-www-form-urlencoded";
55 <                request.Credentials = cache;
55 >                request.Headers = headers;
56                  request.KeepAlive = false;
57                  request.Method = "POST";
45                request.PreAuthenticate = true;
58                  request.UserAgent = "Host Update Sharp/1.0 (" + platform() + ')';
59  
60                  StreamWriter post = new StreamWriter(request.GetRequestStream(),
# Line 56 | Line 68 | public class HostUpdateSharp
68                  StreamReader content = new StreamReader(response.GetResponseStream(),
69                          Encoding.ASCII);
70  
71 <                Console.Write(content.ReadToEnd());
71 > #if _FreeBSD_
72 >                if (debug) Console.Write(content.ReadToEnd());
73 > #else
74 >                if (debug) MessageBox.Show(content.ReadToEnd(), "Host Update Sharp",
75 >                        MessageBoxButtons.OK, MessageBoxIcon.Information);
76 > #endif
77 >
78                  content.Close();
79          }
80 +        private static bool debug = false;
81   #if _FreeBSD_
82          private string platform() { return "FreeBSD 4.9-STABLE i386"; }
83   #else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines