HyperText Transport Protocol

 

The HTTP protocol is a request/response protocol used by the World Wide Web. A client sends a request to the server and the server sends a reply.  HTTP is an application layer protocol that is built on top of TCP/IP.  The protocol sends requests and responses in ASCII characters that can easily be read.  The request is always terminated by a blank line.  The format of the request sent by a client browser (such as Netscape or Internet Explorer) to a web server is:

<Method>  <Request-URI>  <HTTP-Version>  <Request options> CRLFCRLF

An example is:

                   GET /mypage.html HTTP/1.1¿

                   HOST: williams.comp.ncat.edu¿

                   ¿

This example requests the server to send the web page, mypage.html, to the client’s browser.  The browser has indicated that it is using version 1.0 of the protocol.  Note that the request is terminated by two end of line characters(¿¿).

The HTTP methods are:

OPTIONS Request the available server options.

GET     Get a file from the server.

HEAD    Get information about a file from the server.

POST    Send information to the server.

PUT     Send a file to be stored on the server.

DELETE  Delete a file on the server.

TRACE   invoke a loop-back of the request message.

 

The server responds with a status line, including the message's protocol version and a success or error code and possibly message content.

 

                   HTTP/1.1 <status code> <reason>¿

                   <response options>¿

                   ¿

                   <file contents>

 

An example response from a server could be:

 

HTTP/1.1 200 OK

Date: Sun, 26 Nov 2000 23:48:00 GMT

Server: Apache/1.3.6 (Win32)

Last-Modified: Fri, 17 Nov 2000 12:51:44 GMT

ETag: "0-124b-3a1529e0"

Accept-Ranges: bytes

Content-Length: 4683

Connection: close

Content-Type: text/html

 

<html>

<head> etc.


Some of the status codes returned by the server are:

1xx: Informational  Request received, continuing process

2xx: Success        The action was successfully received, understood, and accepted

200 OK

3xx: Redirection    Further action must be taken in order to complete the request

301 Moved Permanently

304 Not Modified

4xx: Client Error   The request contains bad syntax or cannot be fulfilled

400 Bad Request

401 Unauthorized

402 Payment Required

403 Forbidden

404 Not Found

410 Gone

5xx: Server Error   The server failed to fulfill an apparently valid request

500 Internal Server Error

 

 

The usual operation for getting a web page from a server under HTTP/1.0 is:

Create a socket.

Connect to the server at port 80.

Send a GET request to the server for the desired file.

                                                                                                        Send a header describing the file.

                                                                                                                  Send the contents of the file.

                                                                                                                             Close the connection.

For each graphic referenced {

            Create a socket.

Connect to the server at port 80.

Send a GET request to the server for the graphic file.

                                                                                          Send a header describing the graphic file.

                                                                                                   Send the contents of the graphic file.

                                                                                                                             Close the connection.

            }

 

HTTP/1.1 provides for keeping a connection open to transfer multiple files.  The above example can be modified to fit HTTP/1.1 as such:

Create a socket.

Connect to the server at port 80.

Send a GET request to the server for the desired file.

                                                                                                        Send a header describing the file.

                                                                                                                  Send the contents of the file.

For each graphic referenced {

Send a GET request on the existing server connection for the graphic file.

                                                                                          Send a header describing the graphic file.

                                                                                                   Send the contents of the graphic file.

            }

 

The HyperText Transport Protocol is defined by RFC2616 of the Internet Engineering Task Force (IETF).