Skip to content

HTTP

Also called: HTTPS, Hypertext Transfer Protocol, HTTP protocol

Published:

How does HTTP work?

RFC 9110, the IETF standard that defines HTTP semantics, describes it as a stateless application-level protocol for distributed, collaborative, hypertext information systems [1]. MDN calls it the foundation of any data exchange on the web: a client-server protocol in which the client, usually the browser, always initiates the request [2].

Clients and servers exchange individual messages rather than a stream of data. What the client sends are requests, and what the server sends back are responses [2]. In MDN's example, the browser sends the request below and the server replies with a response that starts with "HTTP/1.1 200 OK" and carries the HTML page [2]:

http
GET / HTTP/1.1
Host: developer.mozilla.org
Accept-Language: fr

The GET method requests transfer of a current representation of the target resource and is one of the safe, essentially read-only methods. A POST body, by contrast, is information for the target resource to process [1].

What does stateless mean?

There is no link at the protocol level between two requests made one after another on the same connection [2]. Sites that keep you logged in get around this with cookies: the core of HTTP stays stateless, but cookies make stateful sessions possible [2].

How is HTTP different from HTTPS?

HTTPS is the encrypted version of HTTP, using TLS to encrypt all communication between client and server [3]. Under RFC 9110, a client must make sure the connection is secured before sending a request for an "https" resource, and the default port is 443 [1].

Frequently asked questions

Is HTTPS a separate protocol?

HTTPS is HTTP carried over a TLS-secured connection. The messages mean the same thing; the difference is that traffic is encrypted and the server is authenticated.

Why is HTTP called stateless?

Because the protocol does not link one request to the next on its own. Session information is carried by extra mechanisms such as cookies.

Sources

  1. RFC 9110: HTTP Semantics — IETF / RFC Editor
  2. Overview of HTTP — MDN Web Docs
  3. HTTPS - Glossary — MDN Web Docs