Tests whether the specified HTTP header can be set for the request.
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
class MainClass
{
public static void Main()
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create("http://www.msn.com");
HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse();
WebHeaderCollection myWebHeaderCollection = myHttpWebResponse.Headers;
for (int i = 0; i < myWebHeaderCollection.Count;i++)
{
if(WebHeaderCollection.IsRestricted(myWebHeaderCollection.AllKeys[i]))
Console.WriteLine("'{0}' is a restricted header", myWebHeaderCollection.AllKeys[i]);
else
Console.WriteLine("'{0}' is not a restricted header", myWebHeaderCollection.AllKeys[i]);
}
myHttpWebResponse.Close();
}
}
Related examples in the same category