Gets or sets the value of the Connection HTTP header. : HttpWebRequest « Network « C# / C Sharp






Gets or sets the value of the Connection HTTP header.

   
using System.Net;
using System;
using System.IO;
class MainClass
{
    static void Main()
    {
        HttpWebRequest myHttpWebRequest1 = (HttpWebRequest)WebRequest.Create("http://www.google.com");

        myHttpWebRequest1.KeepAlive = false;
        HttpWebResponse myHttpWebResponse1 = (HttpWebResponse)myHttpWebRequest1.GetResponse();

        Console.WriteLine(myHttpWebRequest1.Headers);

        Stream streamResponse = myHttpWebResponse1.GetResponseStream();
        StreamReader streamRead = new StreamReader(streamResponse);
        Char[] readBuff = new Char[256];
        int count = streamRead.Read(readBuff, 0, 256);
        while (count > 0)
        {
            String outputData = new String(readBuff, 0, count);
            Console.Write(outputData);
            count = streamRead.Read(readBuff, 0, 256);
        }
        streamResponse.Close();
        streamRead.Close();
    }
}

   
    
    
  








Related examples in the same category

1.Begins an asynchronous request for a Stream object to use to write data.
2.Gets or sets the cookies associated with the request.
3.Downloads a web page from the Internet and returns a string.
4.Performs online file transfer operations.