Network Programming in .NET: With C# and Visual Basic .NET

4.2: HTTP

4.2 HTTP

HTTP operates on TCP/IP port 80 and is described definitively in RFC 2616. The protocol is quite straightforward. The client opens TCP port 80 to a server, the client sends an HTTP request, the server sends back an HTTP response, and the server closes the TCP connection.

4.2.1 The HTTP Request

The simplest HTTP request is as follows:

GET /
Tip

On some servers, it is necessary to specify the DNS name of the server in the GET request.

This request will instruct the server to return the default Web page; however, HTTP requests are generally more complex, such as the following:

GET / HTTP/1.1Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,application/vnd.ms-powerpoint, application/vnd.ms-excel,application/msword, */*Accept-Language: en-gbAccept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT5.1; .NET CLR 1.0.3705)Host: 127.0.0.1:90Connection: Keep-Alive

This tells the server several things about the client, such as the type of browser and what sort of data the browser can render.

Table 4.1 shows a complete list of standard HTTP request headers are as follows:

Table 4.1: Standard HTTP request headers .

HTTP header

Meaning

Accept

Used to specify which media (MIME) types are acceptable for the response. The type */* indicates all media types and type/* indicates all subtypes of that type. In the example above, application/msword indicates that the browser can display Word documents.

Accept-Charset

Used to specify which character sets are acceptable in the response. In the case where a client issues Accept-Charset: iso-8859-5, the server should be aware that the client...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Web Application Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.