Bookmarks

HTTP — HTTP

Hypertext Transfer Protocol

A set of application-layer rules by which a client and a server exchange data on the web: a request with a method and an address, a response with a status and a body.

Also: Hypertext Transfer Protocol, HTTP protocol

checked 9 Nov

All terms

Almost everything a browser does on the internet is HTTP: opening a page, submitting a form, fetching data for an interface. Services talk to each other the same way: a REST API is built on HTTP, and a mobile app calls its backend over it. The protocol appeared in 1990 together with the web itself and has remained its main way of transferring data ever since.

How a request and response work

HTTP follows a “request and response” pattern: the client sends a request, the server returns a response, and the exchange is over. The protocol is stateless: each request is understandable on its own, and the server does not remember earlier ones. The roles are tied not to programs but to a connection: the same service can be a client in one connection and a server in another.

httpAn HTTP/1.1 request and response are text messages: start line, headers, a blank line, body
GET /articles/42 HTTP/1.1Host: glob.uzAccept: application/json HTTP/1.1 200 OKContent-Type: application/jsonCache-Control: max-age=60 {"id": 42, "title": "…"}
MethodWhat it doesIdempotent
GETreads a resource, with no side effectsyes
HEADlike GET, but without a body — headers for checkingyes
POSTcreates a resource or starts processingno
PUTreplaces a resource entirelyyes
PATCHchanges a resource partiallyno
DELETEdeletes a resourceyes

The method says what to do with the resource. The status code says what happened: 200 is success, 301 and 308 mean moved permanently, 404 means the resource does not exist, 500 is a server error. The 3xx, 4xx and 5xx codes, together with headers such as Location and Retry-After, tell the client what to do next.

Versions: HTTP/1.1, HTTP/2, HTTP/3

VersionYearTransportMain change
HTTP/1.11997TCPpersistent connections, chunked transfer; still the baseline
HTTP/22015TCPbinary format, multiplexing of requests in one connection
HTTP/32022QUIC over UDPfast handshake, no head-of-line blocking at the transport level

In HTTP/1.1, several parallel requests required several connections. HTTP/2 packed requests into frames inside a single TCP connection and compressed headers, but the loss of one TCP packet stalled all requests at once. HTTP/3 moved connection management into QUIC: streams are independent, and a lost packet delays only the requests it affects. All versions share the same semantics, defined in RFC 9110, so client and server pick a version according to their own and the network’s capabilities.

State and caching

State is kept not in the protocol but in headers: cookies carry a session identifier, and Authorization carries an access token. Caching is also an agreement expressed in headers: Cache-Control and ETag let a browser or proxy avoid downloading an unchanged resource again and instead send a conditional request and get a short 304 response.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • HTTPSHTTPS

    HTTPS is the same HTTP, but inside a connection encrypted with TLS: without it, traffic can be read at every hop along the way.

  • RESTREST

    REST is an architectural style for APIs over HTTP: it sets the rules for working with resources, while HTTP is the way the exchange itself happens.

In depth in the references

where the topic is covered in detail