Using the HyperText Transport Protocol

When most people think of the World Wide Web, they think of web pages that are coded in HTML, but that’s only part of the web. In order to simplify transfer of documents and files, another file transport protocol was developed. This is known as the HyperText Transport Protocol, or HTTP.

NOTE: HTTP is not HTML: Although this may appear to be obvious, many people get confused. HTTP is one way to transfer a document from a server to a client. HTML is a language used to encode a specific type of document. A web browser combines the ability to retrieve an HTML document and display it. A browser could also use FTP to retrieve an HTML document and display it, and you can also use HTTP to retrieve and save an .EXE file.

HTTP Commands

Like FTP, HTTP also uses commands to access information. Unlike FTP, HTTP commands are not used as part of a session. Each command is issued as a stand-alone command, and the server doesn’t have any previous memory of any other commands. This means that security information, if required, as well as any identity information the client wishes to send, must be sent each time.

While not as rich as the set of commands in FTP, the HTTP commands allow you to retrieve an entire document and send documents to the web server. The exact set of commands varies from web server to web server, but all allow you to retrieve an entire document or only the document’s header information. Also, most web servers can receive information and process it using a program on the web server.

The server will respond to each command sent with a multiple-line message. The first line contains the version of HTTP the server understands followed by a space and a three-digit reply code. The reply code is similar to the reply code used by FTP, with the same meanings for the leading digit. It differs only in the actual meaning of each individual code.

Header Information

Accompanying the request sent to the server and the server’s response to the client is usually one or more lines of header information. Headers are composed of a keyword ending in a colon (:), followed by a space and then the value.

Headers are used to convey information such as the e-mail address of the person making the request, the authorization information, the name of the client software, or the date the document was last modified. Headers are also used to describe the type of document being sent, by sending information such as the length of the document, the type of the document, and how the document was compressed.

© 1998 SYBEX Inc. All rights reserved.