What is HTTP? | HyperText Transfer Protocol Explained

HTTP (HyperText Transfer Protocol) is the foundation of data communication on the web. Learn how HTTP works, what HTTP methods and status codes mean, the difference between HTTP and HTTPS, and how HTTP/1.1, HTTP/2, and HTTP/3 compare.

HTTP (HyperText Transfer Protocol) is the application-layer protocol that defines how clients and servers exchange data on the web. Every website visit, API call, and file download uses HTTP.


TL;DR HTTP is the set of rules that governs how browsers and servers communicate. A browser sends an HTTP request (e.g., GET /index.html); the server returns an HTTP response with a status code and content. HTTP is stateless — each request is independent. HTTPS is HTTP secured with TLS encryption. HTTP/1.1 (1997) opened one connection per request; HTTP/2 (2015) multiplexed many requests over one connection; HTTP/3 (2022) replaced TCP with QUIC for lower latency. Every web interaction uses HTTP at its core.


What is HTTP?

HTTP (HyperText Transfer Protocol) is an application-layer protocol that defines the format and rules for communication between clients (browsers, apps, APIs) and servers. It is the foundation of the World Wide Web.

HTTP operates on a request-response model:

  1. A client sends an HTTP request to a server.
  2. The server processes the request and returns an HTTP response.

HTTP is stateless — each request is completely independent. The server has no memory of previous requests from the same client. Cookies, sessions, and tokens are used to maintain state across requests at the application layer.

HTTP runs over TCP (HTTP/1.1 and HTTP/2) or QUIC/UDP (HTTP/3). HTTPS is HTTP with TLS encryption added at the transport layer.


The HTTP request-response cycle

HTTP request structure

GET /products?category=shoes HTTP/1.1
Host: shop.example.com
Accept: application/json
Authorization: Bearer eyJhbGci...
User-Agent: Mozilla/5.0

An HTTP request has four parts:

  1. Request line — method, path, HTTP version
  2. Headers — metadata about the request (host, content type, authentication)
  3. Blank line — separates headers from body
  4. Body (optional) — data sent with POST, PUT, PATCH requests

HTTP response structure

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 342
Cache-Control: max-age=3600
{"products": [...]}

An HTTP response has:

  1. Status line — HTTP version, status code, reason phrase
  2. Headers — metadata about the response
  3. Blank line
  4. Body — the requested content

HTTP methods

HTTP methods (also called verbs) define the intended action of the request:

MethodPurposeHas bodyIdempotentSafe
GETRetrieve a resourceNoYesYes
POSTCreate a resource or submit dataYesNoNo
PUTReplace a resource entirelyYesYesNo
PATCHPartially update a resourceYesNoNo
DELETERemove a resourceNoYesNo
HEADSame as GET but no response bodyNoYesYes
OPTIONSDiscover server capabilities (used in CORS preflight)NoYesYes

Idempotent means making the same request multiple times produces the same result. Safe means the method doesn’t change server state.


HTTP status codes

Status codes are three-digit numbers that tell the client the result of the request:

RangeCategoryCommon examples
1xxInformational100 Continue, 101 Switching Protocols
2xxSuccess200 OK, 201 Created, 204 No Content
3xxRedirection301 Moved Permanently, 302 Found, 304 Not Modified
4xxClient error400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests
5xxServer error500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout

The first digit defines the category. 4xx means the client made an error. 5xx means the server failed.


Key HTTP headers

Request headers

HeaderPurposeExample
HostTarget server domainHost: api.example.com
AuthorizationAuthentication credentialsAuthorization: Bearer <token>
Content-TypeFormat of the request bodyContent-Type: application/json
AcceptFormats the client can handleAccept: application/json
Cache-ControlCaching directivesCache-Control: no-cache
User-AgentClient software identifierUser-Agent: Mozilla/5.0

Response headers

HeaderPurposeExample
Content-TypeFormat of the response bodyContent-Type: text/html; charset=utf-8
Cache-ControlHow long to cache the responseCache-Control: max-age=3600
LocationRedirect target URLLocation: https://example.com/new
Set-CookieSet a cookie on the clientSet-Cookie: session=abc; HttpOnly
Strict-Transport-SecurityEnforce HTTPSStrict-Transport-Security: max-age=31536000

HTTP versions compared

FeatureHTTP/1.1HTTP/2HTTP/3
Year199720152022
TransportTCPTCPQUIC (UDP)
MultiplexingNo (one request per connection)Yes (many requests per connection)Yes
Header compressionNoYes (HPACK)Yes (QPACK)
Head-of-line blockingYesYes (at TCP level)No
TLS requiredNoIn practice yes (browsers require it)Yes (built in)
Connection setupTCP handshakeTCP + TLS handshakeQUIC (1-RTT or 0-RTT)

HTTP/1.1 opens a new TCP connection for each request (or reuses connections with keep-alive, but still serializes requests). HTTP/2 sends multiple requests simultaneously over one connection. HTTP/3 eliminates TCP head-of-line blocking by using QUIC over UDP — packet loss on one stream doesn’t stall others.


HTTP vs HTTPS

 HTTPHTTPS
Port80443
EncryptionNoneTLS
AuthenticationNoneServer certificate
Data integrityNot guaranteedGuaranteed by TLS
SEOPenalized by GoogleRequired for ranking
Browser indicator”Not secure” warningPadlock icon

HTTPS is HTTP with a TLS layer added. The TLS handshake happens before any HTTP data flows. All HTTP content — including headers, cookies, and request bodies — is encrypted in HTTPS.


Frequently asked questions

What is HTTP in simple terms? HTTP is the language browsers and web servers use to talk to each other. When you type a URL and press Enter, your browser sends an HTTP request asking for that page. The server sends back an HTTP response containing the HTML. HTTP defines the format of both messages.

What is the difference between HTTP and HTTPS? HTTPS is HTTP with TLS encryption. In HTTP, all data travels in plaintext — anyone between you and the server can read it. In HTTPS, TLS encrypts the connection so only the client and server can read the data. Modern browsers require HTTPS and warn users about HTTP sites.

What does HTTP stateless mean? HTTP stateless means each request is completely independent — the server doesn’t remember previous requests from the same client. Every request must contain all the information needed to process it. Applications maintain state (like login sessions) using cookies, tokens, or server-side sessions layered on top of HTTP.

What is the difference between GET and POST? GET retrieves data and should have no side effects — it’s safe and idempotent. GET parameters go in the URL. POST submits data to the server (creating or modifying resources) and has a request body. POST is not idempotent — calling it twice creates two resources.

What does a 404 error mean? A 404 Not Found error means the server received and understood the request, but could not find the requested resource. The resource may never have existed, may have been deleted, or the URL may be wrong. It’s a client error (4xx) because the client requested something that isn’t there.

What is HTTP/2 and why is it faster? HTTP/2 introduced multiplexing — sending multiple requests simultaneously over a single TCP connection. HTTP/1.1 sent requests one at a time per connection (or opened many parallel connections). HTTP/2 also compresses headers (HPACK) and allows servers to push resources proactively. The result is significantly fewer connection overhead and faster page loads.

What is HTTP/3? HTTP/3 replaces TCP with QUIC, a transport protocol built on UDP. QUIC integrates TLS 1.3 directly, reducing connection setup to 1-RTT (or 0-RTT for returning connections). It eliminates head-of-line blocking — in HTTP/2 over TCP, one lost packet stalls all streams; QUIC handles each stream independently. HTTP/3 is especially beneficial on mobile networks where packet loss is common.

What is an HTTP header? An HTTP header is a key-value pair sent in an HTTP request or response that provides metadata. Request headers tell the server about the client (Accept language, Authorization token, Content-Type of the body). Response headers tell the client about the response (Content-Type of the body, Cache-Control directives, security policies like HSTS).

stay up to date

Subscribe to our Newsletter

Get the latest product updates, event highlights, and tech industry insights delivered to your inbox.