The RSS Blog

News and commentary from the RSS and OPML community.

I just wrote a neat little utility for running HTTP GET request. I use it to look at RSS request HTTP headers when RSS users need a little help. The core of the utility is what happens when you click the GO button. Here's open source for you.

System.Uri uri = new Uri(this.textBoxAddress.Text);
System.Net.Sockets.TcpClient client =
new System.Net.Sockets.TcpClient();
client.Connect(uri.Host, uri.Port);
System.Net.Sockets.NetworkStream stream = client.GetStream();
string req = "GET " + uri.PathAndQuery + " HTTP/1.1\r\nHost: " + uri.Host + "\r\n\r\n\r\n";
this.textBox.Text = req;
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(req);
stream.Write(bytes, 0, bytes.Length);
stream.Flush();
for(int i=0;i<100;i++)
{
  
if (stream.DataAvailable)
  
{
     
break;
   }
   System.Threading.Thread.Sleep(100);
}
bytes =
new byte[1024];
System.Text.StringBuilder sb =
new System.Text.StringBuilder();
sb.Append(req);
while (stream.DataAvailable)
{
  
int count = stream.Read(bytes, 0, 1024);
  
if (count == 0)
   {
     
break;
   }
   sb.Append(System.Text.Encoding.UTF8.GetString(bytes, 0, count));
}
this.textBox.Text = sb.ToString();

Ya, it's just a regular old HTTP request, but done at the TCP level so I can dump all the bytes. Don't use it to view the RSS, I use it to get the HTTP headers and stop there. You can download the zipped utility right here. Enjoy!

Type "339":