The HTTP protocol

HTTP is a text-based client-server protocol that runs over TCP. Plain HTTP runs over TCP port 80.

It should be noted that plain HTTP is mostly deprecated for security reasons. Today, sites should use HTTPS, the secure version of HTTP. HTTPS secures HTTP by merely running the HTTP protocol through a Transport Layer Security (TLS) layer. Therefore, everything we cover in this chapter regarding HTTP also applies to HTTPS. See Chapter 9, Loading Secure Web Pages with HTTPS and OpenSSL, for more information about HTTPS.

HTTP works by first having the web client send an HTTP request to the web server. Then, the web server responds with an HTTP response. Generally, the HTTP request indicates which resource the client is interested in, and the HTTP response delivers the requested resource.

Visually, the transaction is illustrated in the following graphic:

The preceding graphic illustrates a GET request. A GET request is used when the Web Client simply wants the Web Server to send it a document, image, file, web page, and so on. GET requests are the most common. They are what your browser sends to a Web Server while loading up a web page or downloading a file.

There are a few other request types that are also worth mentioning.