using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
foreach (string key in response.Headers.AllKeys)
{
Console.WriteLine(String.Format("{0}: {1}", key, response.Headers[key]));
}
}
Complete code:
HttpWebRequest request = WebRequest.Create(_url) as HttpWebRequest;
request.Method = "GET";
request.Headers.Add("AuthToken", _token);
request.ContentLength = 0;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
Console.WriteLine("{0} {1}", (int)response.StatusCode, response.StatusCode);
foreach (string key in response.Headers.AllKeys)
{
Console.WriteLine(String.Format("{0}: {1}", key, response.Headers[key]));
}
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
Console.WriteLine("\n{0} ", reader.ReadToEnd());
}
}
No comments:
Post a Comment