HTTP (HyperText Transfer Protocol) is the set of rules a browser and a web server use to exchange web pages and other data. In the request response cycle, the client sends a request naming what it wants, the server processes it and sends back a response containing a status code, headers and usually a body such as HTML or JSON.
Every time you open a page, submit a form or load an image, at least one HTTP exchange happens. Understanding this cycle is the foundation for everything else about the web, from APIs to caching.
HTTP is an application-layer protocol. It defines the format of messages, not how bits travel over the network. Underneath, the browser opens a TCP connection (or a QUIC connection for HTTP/3), and secure connections add TLS, which is what HTTPS means.
HTTP is a client-server protocol. The client, normally a browser, always starts the conversation. The server waits for requests and answers them. A server cannot send an ordinary HTTP response unless a request came first.
HTTP is also stateless: each request is independent, and the server does not remember earlier requests by default. Sites that need to remember you, for example to keep you logged in, use cookies or tokens.
When you type https://example.com/products into the address bar, this happens:
A single page usually needs many request response cycles, one for each file. The Network panel in your browser's developer tools lists all of them.
A request has a request line, headers and an optional body. This is a simple one in the HTTP/1.1 text format:
GET) says what action you want./products?category=books) identify the resource.HTTP/1.1) names the protocol version.HTTP/2 and HTTP/3 send the same information in a binary format rather than plain text, but the ideas (method, path, headers, body, status) are identical, and tools show them in the same way.
The server answers with a status line, headers and a body:
200) and reason phrase (OK) report the outcome. Codes beginning with 2 mean success, 3 redirection, 4 a client error and 5 a server error.You can watch the cycle yourself with curl. The -i flag prints the response headers along with the body, and -v also shows the request that was sent.
You can do the same from JavaScript in a browser or in Node.js 18 and later with the Fetch API:
fetch() sends the request, and the returned Response object exposes the status, headers and body.
| Version | Main idea |
|---|---|
| HTTP/1.1 | Text-based; one request at a time per connection, so browsers open several connections |
| HTTP/2 | Binary; many requests share one connection (multiplexing) and headers are compressed |
| HTTP/3 | Runs over QUIC instead of TCP, which reduces delay when packets are lost |
Browsers and servers negotiate the best version automatically. Plain HTTP sends data readable by anyone on the path, so modern sites use HTTPS, which encrypts the traffic and verifies the server's identity with a certificate. Browsers mark HTTP-only pages as not secure.
Each request is handled on its own, with no built-in memory of earlier ones. Cookies, sessions and tokens are added on top to remember users.
HTTPS is HTTP carried over a TLS encrypted connection. The messages have the same format, but they are protected from eavesdropping and tampering.
No. The internet is the global network. HTTP is one protocol that runs over it, alongside others such as SMTP for email.
HTTP uses port 80 by default and HTTPS uses port 443. Browsers hide the default port in the address bar.
HTTP is a stateless, client-server protocol. The client sends a request with a method, path, headers and an optional body, and the server returns a response with a status code, headers and a body. One page load involves many such cycles, and HTTPS adds encryption. Related articles cover methods, status codes and headers in detail.