using System;
using System.IO;
using System.Net;
public class TryHttpRequest {
public static void Main(String [] args) {
HttpWebRequest request =(HttpWebRequest)WebRequest.Create("http://www.java2java.com");
HttpWebResponse response =(HttpWebResponse)request.GetResponse();
request.Accept = "text/plain";
Console.WriteLine("Request header count: {0}",request.Headers.Count);
WebHeaderCollection header = request.Headers;
for (int i = 0; i < header.Count; i++)
Console.WriteLine(" {0} : {1}",header.GetKey(i), header[i]);
}
}
|