HTTP: Master the Protocol Behind Web Communication

HTTP is the application-layer protocol that enables clients and servers to exchange information on the Web through a request-response model. In this handout, we will analyse the structure of an HTTP request, including methods, targets, headers and optional bodies, and the structure of an HTTP response, including status lines, headers and returned content. We will also study HTTP methods such as GET, POST, PUT, PATCH and DELETE, and learn how HTTP status codes communicate success, redirection, client errors and server errors. Finally, we will examine persistent connections and the role of HTTPS in protecting communication through TLS.

HTTP

Key points

  • HTTP (Hypertext Transfer Protocol) = application-layer protocol for exchanging Web resources through a client-server request-response communication model.
  • HTTP ≠ HTTPS: HTTPS uses TLS to protect communication through encryption and verification of the remote service; default ports → 80 and 443, respectively.
  • HTTP communication → client sends a request → server processes it → server returns a response → client interprets the result.
  • HTTP request = message asking a server to perform an operation on a resource; HTTP/1.1 structure → request line, headers, blank line, optional body.
  • Request line = METHOD TARGET VERSION; the target commonly includes the path and query, while URL fragments are not transmitted to the server.
  • HTTP methods → GET retrieves, HEAD requests metadata without response content, POST submits data for processing, PUT replaces, PATCH partially modifies, DELETE removes resource associations.
  • GET is a safe method → requests retrieval without asking the server to modify resource state; secondary activities such as logging remain possible.
  • Request headers → provide contextual information; Host identifies the destination, User-Agent identifies the client, and Accept indicates preferred response formats.
  • Accept ≠ Content-Type: Accept expresses which formats the client prefers to receive, while Content-Type describes the format of transmitted content.
  • Request body = optional data sent to the server, commonly with POST, PUT, or PATCH; its interpretation depends on method semantics and media type.
  • HTTP response = message communicating the outcome of a request; HTTP/1.1 structure → status line, headers, blank line, optional body.
  • Status codes → 1xx informational, 2xx successful, 3xx redirection, 4xx client-related problems, 5xx server-related problems; numeric codes take precedence over reason phrases.
  • Common success and redirection codes → 200 successful, 201 resource created, 204 no content, 301 permanent redirect, 302 temporary redirect, 304 cached response reusable.
  • Common error codes → 400 invalid request, 401 missing or invalid authentication, 403 forbidden, 404 resource not found, 429 excessive requests.
  • Server error codes → 500 unexpected server error, 502 invalid upstream response, 503 temporarily unavailable service.
  • Response headers → Content-Type describes the media format, Content-Length indicates size, Location identifies another URL, and Content-Encoding indicates applied content encoding.
  • Cache and session management → Cache-Control defines response reuse rules; Set-Cookie instructs the browser to store a cookie under specified conditions.
  • Response body → carries resources, data, or error information; it may be absent depending on the method, status code, and HTTP rules.
  • Persistent connections → allow multiple HTTP exchanges without repeatedly establishing connections; loading a Web page can generate separate requests for its resources.

Do you want to help me write articles like this one?

Leave a Reply

Your email address will not be published. Required fields are marked *

No responses yet

Sostieni il progetto

Tutti i materiali che condivido nascono da una convinzione molto semplice: una buona formazione non dovrebbe limitarsi a insegnare quali pulsanti premere, ma aiutare a comprendere le idee, i principi e i processi che stanno dietro agli strumenti.

Per questo dedico una parte significativa del mio tempo a studiare, organizzare e produrre contenuti gratuiti dedicati al multimedia, al design e alla comunicazione visiva. Articoli, lezioni, approfondimenti e risorse che hanno l’obiettivo di rendere accessibili argomenti spesso affrontati in modo frammentario o superficiale.

Questo lavoro richiede però tempo, ricerca e cura. Ogni guida, ogni video, ogni materiale pubblicato gratuitamente è il risultato di molte ore di studio, scrittura e revisione.
Sostenere il progetto attraverso Patreon significa permettermi di continuare a produrre contenuti educativi di qualità, mantenerli accessibili al maggior numero possibile di persone e dedicare più energie alla costruzione di una risorsa che possa essere utile a studenti, professionisti e appassionati.

Se credi che una conoscenza più profonda, rigorosa e consapevole del multimedia abbia valore, il tuo contributo non sostiene soltanto il mio lavoro: aiuta a rendere queste risorse disponibili per tutta la comunità.
Grazie per il supporto e per la fiducia.

Patreon è troppo impegnativo?

Puoi sostenermi anche con una donazione libera, senza abbonamento e senza impegno.
Anche un piccolo contributo mi aiuta a continuare a creare giochi, contenuti didattici e materiali gratuiti con più libertà.

Support the project

All the materials I share stem from a very simple conviction: good training should not be limited to teaching which buttons to press, but should help people understand the ideas, principles, and processes behind the tools.

That is why I dedicate a significant portion of my time to researching, organizing, and producing free content focused on multimedia, design, and visual communication—articles, lessons, in-depth analyses, and resources aimed at making accessible topics that are often addressed in a fragmented or superficial way.

However, this work requires time, research, and care. Every guide, video, and piece of material published for free is the result of many hours of study, writing, and revision.
Supporting the project via Patreon enables me to continue producing high-quality educational content, keep it accessible to as many people as possible, and devote more energy to building a resource that benefits students, professionals, and enthusiasts alike.

If you believe that a deeper, more rigorous, and informed understanding of multimedia is valuable, your contribution does more than just support my work: it helps make these resources available to the entire community.
Thank you for your support and trust.

Is Patreon too demanding?

You can also support me with a voluntary donation—no subscription or commitment required.

Even a small contribution helps me continue creating games, educational content, and free materials with greater freedom.