5 // This program dumps the results of the HTTP request without any HTTP
11 using System.Net.Sockets;
14 static NetworkStream ns;
15 static StreamWriter sw;
16 static StreamReader sr;
22 static void send (string s)
25 Console.WriteLine (s);
31 static void Main (string [] args)
35 while (args [i].StartsWith ("-")){
36 if (args [i] == "-debug")
38 if (args [i] == "-headers")
40 if (args [i] == "-header")
45 c = new TcpClient (args [i], Int32.Parse (args [i+1]));
46 c.ReceiveTimeout = 1000;
49 sw = new StreamWriter (ns);
50 sr = new StreamReader (ns);
52 string host = args [i];
53 if (args [i+1] != "80")
54 host += ":" + args [i+1];
55 send (String.Format ("GET {0} HTTP/1.1\r\nHost: {1}\r\n\r\n", args [i+2], host));
57 MemoryStream ms = new MemoryStream ();
60 byte [] buf = new byte [1024];
63 while ((n = ns.Read (buf, 0, 1024)) != 0){
69 sr = new StreamReader (ms);
73 while ((s = sr.ReadLine ()) != null){
78 string x = sr.ReadToEnd ();
83 Console.WriteLine (s);
84 if (header != null && s.StartsWith (header)){
85 Console.WriteLine (s);