In this, it describes the HTTP protocol in more details. In particular, it does define the structure of the request and response streams.
Hypertext Transfer Protocol (HTTP):
- In any communication protocol, the client must transmit a request and the server should transmit some meaningful response.
- In HTTP, request is some resource that is specified by the URL. If the URL is specified by some static document, then the response includes the text of that document.
- You can think of the request and response as envelopes around the URL (plus form data)and the response text.
- The figure given below does show the client server architecture:
An HTTP request can be made using a variety of methods. The table given below lists the HTTP methods and their descriptions.
|OPTIONS||Request for the communication options available on the request/response chain|
|GET||Request to retrieve an information identified by the request URI|
|HEAD||Identical to the GET except that it does not return a message body, only a headers|
|POST||Request for the server to accept the entity enclosed In the body of the HTTP response|
|PUT||Request for the server to store the entity enclosed In the body of the HTTP response|
|DELETE||Request for the server to delete the resource identified by the Request URI|
|TRACE||Request for the server to invoke an application layer loop back of the request message|
|CONNECT||Reserved for use with a proxy that can switch to being a tunnel|
HTTP GET Method:
- The most common HTTP method is the GET request. The GET method is used whenever an user clicks a hyperlink in the HTML page currently being viewed.
- A GET method is also used when the user enters a URL into the Location field (for Netscape Navigator and Firefox) or the Address field (for Microsoft Internet Explorer).
- While processing a web page, the browser also issues GET requests for images, applets, style sheet files, and other linked media.
- The request stream acts as an envelope to the URL and message body of the HTTP client request.
- The first line of the request stream is called the request line. It includes the HTTP method (usually either GET or POST), followed by a space character, followed by a requested URL (usually a path to the static file), followed by the space, and finally followed by the HTTP version number.
- The request header includes the header name (for example User agent), followed by a colon character (and space), and followed by the value of the header.
- The list of headers ends witha blank line. After the blank line, there is an optional message body.
- The figure given below shows an example HTTP request stream.
HTTP Request Stream Example
HTTP Request Headers:
The table given below illustrates some of the HTTP headers that the browser can place in the request. The headers could then be used to determine how the server processes the request.
Some HTTP Request Headers:
|Accept||The MIME types the client can receive|
|Host||The internet host and port number of the resource being requested|
|Referrer||The address from which the request URI was obtained|
|User Agent||The information about the client originating the request|
- The response stream acts as an envelope to the message body of the HTTP server response. The first line of the response stream is called the status line.
- The status line includes the HTTP version number, followed by the space, followed by numeric status code of the response, followed by the space, and finally followed by the short text message represented by the status code.
- The status line is followed by any number of response header lines.The response headers conform to the same structure as request headers.
- The figure given below shows an example HTTP response stream.
HTTP Response Stream Example
HTTP Response Headers:
The table given below illustrates some of the HTTP headers that the server can place in the response. The headers could then be used to determine how the browser processes the response.
Some HTTP Response Headers:
|Content-Type||A MIME type (such as text/html), which classifies the type of the data in the response|
|Content-Length||The length (in bytes) of the payload of the response|
|Server||An informationalstring about the server that responded to this HTTP request|
|Cache Control||A directive for the web browser (or proxies) to indicate whether the content of the response should be cached.|
In this way, you can use HTTP request and response headers.