Tuesday 22 February 2011

The structure of an HTTP response

An HTTP message sent by a server to a client is called an HTTP response.The initial line of HTTP response is called the status line. It has three parts, separated by spaces: the HTTP version, a response status code that tells the result of the request, and an english phrase describing the status code.

HTTP defines many status codes: common ones that you have noticed are 200 and 404. Here are two examples of a status line that could be sent in the response:
HTTP/1.0 200 OK
HTTP/1.0 404 Not Found

When the browser receives a status code that implies a problem, it displays an appropriate message to the user. if some data is associated with the response, headers like Content-Type and Content-Length that describe the data may also be present. A typical HTTP response looks like this:

HTTP/1.0 200 OK
Date: Tue, 10 jan 2002 23:56:12 GMT
Content-Type: text/html
Content-Length: 52

No comments:

Post a Comment