# HTTP
HTTP is an Application-layer protocol: it defines how clients and servers exchange web resources, while lower layers deliver those messages across a network.
A useful browser request mental model is:
- The browser parses a URL and resolves its host through DNS.
- Lower network layers establish a route and connection; TLS protects HTTPS communication.
- The browser sends an HTTP request.
- A server returns an HTTP response, which the browser parses and renders.
# Client and server
A client starts a request; a browser is the most common web client. A server receives requests and returns resources or generated data. A web server may serve files directly, while an application server runs business logic and often exposes an API.
# Request-response timeline
In the ordinary HTTP request-response model, the client initiates the exchange and the server responds:
The server may return an HTML document that references separate CSS and JavaScript resources, causing the browser to send additional requests. A server cannot start an ordinary HTTP request toward a client that has not requested it; server-initiated updates require another mechanism, such as WebSocket or Server-Sent Events.
HTTP is stateless: each request should contain the information needed to process it. Cookies, authorization tokens, and application data can connect several requests when a stateful user experience is needed.
Continue with:
# Exercise
Open any HTTP-served page (not a file:// URL) in a browser and use DevTools → Network. Identify the document request, its method, URL, status, response headers, and timing.