What The Heck is HTTP
Every time you open a website, a client asks and a server answers. That simple conversation is HTTP.
What is HTTP?
HyperText Transfer Protocol is a protocol, in other words a set of rules that defines how two computers communicate. It allows a client to fetch resources from a server. A resource can be any digital file, like an HTML page, audio, video, and so on.
Like any two parties talking to each other, the client and the server communicate by exchanging messages. Traditionally this happens over TCP, or over TLS encrypted TCP. HTTP can run on top of any transport, as long as that transport is reliable. HTTP/3, for example, runs on QUIC, which itself runs on UDP but adds its own reliability. HTTP/1.x is simple and uses plain text messages, while HTTP/2 and HTTP/3 use a binary format.
Request
A request is a message that a client sends to the server.
Response
A response is a message that the server sends back to the client.
Client <-> Server
The client and the server are the main components of HTTP, in addition to proxies. A client sends a request to the server. Before the request reaches the server, it might pass through multiple proxies. When the request reaches the server, the server processes it and sends back a response, which passes through various proxies and devices such as routers and modems before it gets to the client.
A proxy server is an intermediate program or computer that sits between the client and the server and forwards the traffic.
HTTP characteristics
- HTTP is stateless
- HTTP is extensible
- HTTP needs a reliable transport
Stateless
Stateless means that the HTTP requests from one client to a server are not related to each other in any way, even if they are sent over the same connection.
Even though HTTP is stateless, cookies can be used to build a stateful session, so requests can share the same state every time.
HTTP is extensible
HTTP is easy to extend thanks to the concept of headers. A new feature can be as simple as an agreement between the client and the server about the meaning of some headers. Cookies are one example of this extensibility, and so are caching, authentication, and CORS.
HTTP needs a reliable transport
The main requirement for the transport under HTTP is that it is reliable. Reliable means it cannot lose messages, or at least it reports an error when that happens.
That's why HTTP/1.1 and HTTP/2 run on TCP and not on plain UDP. HTTP/3 uses QUIC, which brings the reliability on top of UDP.
HTTP flow
When a client wants to communicate with a server, these steps happen:
- The client opens a connection, or reuses an existing one, to send one or more requests and receive the responses
- The client sends an HTTP message
- The client receives the response from the server
Uniform Resource Identifier (URI)
A URI is a unique identifier that represents the address of a resource on the internet. Using URIs, we can get resources over the internet, like images, movies, or web pages.
There are two kinds of URI: URL and URN.
Uniform Resource Locator (URL)
The URL is the most widely used form of URI. Like any URI, it identifies the address of the resource, but it also specifies how that resource should be retrieved.
URL Components
Uniform Resource Name (URN)
A URN is also used as an address, but it doesn't depend on the location. A URN is more of a "globally" unique name for a resource, and it identifies that resource no matter where it is right now, or if it was moved.
URN Components
HTTP communication
HTTP is the protocol that connects a client and a server so they can exchange messages. This communication happens in the form of request/response. A request is a message we send from the client to the server, and the response is the reply from the server to the client. These HTTP messages are blocks of data that carry all the information needed for a specific HTTP call.
The diagram above shows a basic HTTP request/response started by a client. The client opens a connection to a server and sends a request message. The message contains all the needed information about the client and the requested resource. The server handles the message and replies with a response message.
Both messages have a specific format and may include optional headers and a body. The body is separated from the headers by an empty line.
The request message starts with the verb GET, a special keyword called the request method. There are more methods than GET, like POST, PUT, PATCH, DELETE, HEAD, and OPTIONS. Each one has its own use case.
Then comes the target, which is the path of the requested resource. The target can be either a full URL or an absolute path.
Then the HTTP version. The version defines the structure of the rest of the message.
HTTP methods
GET: retrieves a resource from the serverPOST: sends data for the server to process, like login data or a new record for the databasePUT: creates a resource or replaces it completelyPATCH: updates part of a resourceDELETE: deletes the resource identified by the request URIHEAD: likeGET, but returns only the headers, without the resource itselfOPTIONS: asks the server which methods and options are supported for a resource
Early versions of the spec also had LINK and UNLINK, but they were removed and you will rarely see them today.

If this was useful
Telc German B1 Exam Success Kit (20/80 Rule)
The 20% of German that keeps showing up in the telc B1 exam. Learn it first and walk in already knowing what to expect. €25