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 88 by Douglas Thrift, 2004-03-01T19:03:40-08:00 vs.
Revision 96 by Douglas Thrift, 2004-03-02T00:26:19-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
11  
12   public class HostUpdateSharp
13   {
14          public static void Main(string[] args)
15          {
16 +                try
17 +                {
18 +                        new HostUpdateSharp();
19 +                }
20 +                catch (Exception exception) { Console.Error.WriteLine(exception); }
21 +        }
22 +        public HostUpdateSharp()
23 +        {
24                  StringBuilder host = new StringBuilder("host=" + Dns.GetHostName());
25                  string url = "http://topsecret.douglasthrift.net/auth/hostupdate.cgi";
26  
# Line 24 | Line 29 | public class HostUpdateSharp
29                          host.Append(".local.douglasthrift.net");
30                  }
31  
32 +                WebHeaderCollection headers = new WebHeaderCollection();
33 +
34 +                headers.Add("Authorization", "Basic " + Convert.ToBase64String((new
35 +                        ASCIIEncoding()).GetBytes("HostUpdate:frell2003")));
36 +
37                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
38  
39                  request.Accept = "text/plain";
40                  request.ContentLength = host.Length;
41                  request.ContentType = "application/x-www-form-urlencoded";
42 <                request.Credentials = new NetworkCredential("HostUpdate", "frell2003");
42 >                request.Headers = headers;
43                  request.KeepAlive = false;
44                  request.Method = "POST";
35                request.PreAuthenticate = true;
45                  request.UserAgent = "Host Update Sharp/1.0 (" + platform() + ')';
46  
47                  StreamWriter post = new StreamWriter(request.GetRequestStream(),
# Line 47 | Line 56 | public class HostUpdateSharp
56                          Encoding.ASCII);
57  
58                  Console.Write(content.ReadToEnd());
59 +                content.Close();
60          }
61   #if _FreeBSD_
62 <        private static string platform() { return "FreeBSD 4.9-STABLE i386"; }
62 >        private string platform() { return "FreeBSD 4.9-STABLE i386"; }
63   #else
64 <        private static string platform()
64 >        private string platform()
65          {
66                  OperatingSystem os = Environment.OSVersion;
67                  string system = "Unknown";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines