HyperText Transfer Protocol (HTTP)
HTTP (HyperText Transfer Protocol) is the foundation of data exchange on the web. Every web page, API call, image, stylesheet, and script reaches its destination through HTTP. Clients send requests to servers, servers return responses, and intermediaries like proxies and CDNs relay messages between them.
HTTP is part of the internet protocol suite alongside DNS, TLS, and TCP.
This page was delivered over HTTP
Every web page, including this one, reaches the browser through an HTTP request and response.
How HTTP works
HTTP follows a request-response model. A client sends a request specifying an HTTP method (the action), a URL (the resource), and Headers (metadata). The server processes the request and returns a response with a status code (the outcome), headers, and an optional body containing the resource data.
GET /api/products HTTP/1.1
Host: www.example.re
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 512
{"products":[...]}
HTTP is stateless by design: each request is self-contained and independent. Cookies and tokens maintain state across exchanges when needed.
HTTP versions
The original HTTP specification dates to the early 1990s with a single-line protocol supporting only GET requests. Each subsequent version addressed the performance and security limitations of its predecessor.
- HTTP/1.0: added HTTP headers, status codes|HTTP status codes, and content types beyond HTML. Each request opened a new TCP connection.
- HTTP/1.1: made persistent HTTP connections the default, allowing multiple request-response exchanges over a single TCP connection.
- HTTP/2: introduced binary framing, multiplexing, and header Compression. Multiple HTTP requests and HTTP responses flow concurrently over one connection.
- HTTP/3: replaced TCP with QUIC, a UDP-based transport with built-in encryption eliminating head-of-line blocking.
Core components
HTTP relies on three core building blocks working together in every exchange:
- HTTP headers: name-value pairs carrying metadata about the message, the client, and the server. Headers control HTTP caching, Authentication, Compression, content negotiation, session state, and security policy.
- HTTP methods: verbs defining the action on a resource. GET retrieves, POST submits, PUT replaces, DELETE removes. Each method carries safety, idempotency, and cacheability properties.
- HTTP status codes: three-digit numbers in the response indicating the outcome. 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error.
Security
Plain HTTP transmits data in cleartext. HTTPS layers HTTP over TLS, encrypting the exchange and providing confidentiality, integrity, and server authentication. HSTS enforces HTTPS for all future connections to a host. Modern browsers mark plain HTTP pages as insecure and restrict sensitive APIs to secure contexts.
To coordinate between clients, servers, and intermediaries, HTTP relies on:
- CORS: controls which origins are permitted to read responses from a different origin. Servers declare allowed origins, methods, and headers through response headers.
- Content Security Policy (CSP): restricts the sources a page loads scripts, styles, images, and other resources from. A strong CSP blocks cross-site scripting and data injection attacks.
- Session cookies: the
Secure,HttpOnly, andSameSiteattributes on cookies prevent interception, script access, and cross-site request forgery. - Authentication: HTTP
defines challenge-response authentication
through
WWW-AuthenticateandAuthorizationheaders. Token-based schemes like Bearer tokens and API keys build on this foundation.
Takeaway
HTTP defines how clients and servers exchange resources across the web. Its request-response model, extensible header system, and layered security mechanisms make every web interaction possible. Understanding HTTP internals is essential for building performant, secure, and crawlable websites.
See also
- HTTP headers
- HTTP methods
- HTTP status codes
- HTTPS
- HTTP caching
- CORS
- Cookies
- Compression
- Content negotiation
- Authentication
- Canonical URLs
- Client Hints
- Conditional Requests
- Data URLs
- Hreflang
- HSTS
- HTTP Connection
- Media Types
- Origins
- Percent-Encoding
- Protocol Upgrade
- Punycode
- Range Requests
- Redirections
- HTTP Request
- Resource Hints
- HTTP Response
- HTTP Sessions
- Soft 404
- HTTP Streaming
- Structured Fields
- URI
- URL
- URN
- WebDAV
- WHIP
- WebSocket
- WebSocket Secure