What is HTTP?
HTTP is the request and response protocol browsers and APIs use to fetch resources over a reliable connection.
Published here , updated · 7 sources · Resume reading
HTTP is the protocol for fetching resources such as HTML documents: clients send requests, servers send responses [1]. It is the foundation of ordinary web data exchange on the public internet [1]. Related: what is an API, what is a server, how DNS works.
Quick start (under a minute)
Fetch response headers only:
curl -sI https://example.comYou should see an HTTP status line (HTTP/2 200 or HTTP/1.1 200), then headers such as content-type. That is a response without downloading the HTML body.
See a real response header block on this host
MDN: HTTP is a client-server protocol. The user agent initiates; the origin server responds [1]. A single web page is usually many requests (HTML, CSS, scripts, images) [1].
Observed on this draft host (curl 8.5.0, 2026-12-03):
HTTP/2 200
date: Thu, 03 Dec 2026 10:01:15 GMT
content-type: text/html; charset=utf-8
server: cloudflare
last-modified: Tue, 01 Dec 2026 18:03:11 GMT
allow: GET, HEAD
accept-ranges: bytes
age: 2
cf-cache-status: HIT
cf-ray: a641baa1beecaa47-IAD
alt-svc: h3=":443"; ma=86400Status 200 means the request succeeded for this GET/HEAD [1] [2]. content-type tells the client how to interpret the body. cf-cache-status is a CDN header, not part of HTTP core, but it shows how proxies sit in the path MDN describes [1].
RFC 9110 consolidates modern HTTP semantics (methods, status codes, header rules) [2]. RFC 9112 documents HTTP/1.1 wire format if you need line-oriented examples [3].
Draw one round trip before TLS details
HTTPS wraps the same HTTP messages in TLS. The method, path, status, and headers remain HTTP [1].
Read a tiny HTTP/1.1 message shape
Teaching snippets often use HTTP/1.1 text for readability [3]. A GET sketch aligned with MDN's overview [1]:
GET / HTTP/1.1
Host: developer.mozilla.org
Accept-Language: enA successful response starts with version, status code, headers, blank line, then body [1] [2]. Common methods include GET (fetch), POST (submit), PUT/PATCH (replace or update), DELETE (remove). Safe/idempotent rules live in RFC 9110 [2].
Headers carry metadata: Content-Type, Cache-Control, Authorization, Cookie. Bodies carry form data, JSON, or HTML when present [1].
Separate name lookup from the HTTP exchange
Before the first HTTP byte, the client usually resolves a hostname (how DNS works). Then TCP (and TLS for HTTPS) opens a connection to the resolved address (what is a server).
When someone says "the API is down," ask which layer failed: DNS, TCP, TLS handshake, or an HTTP status such as 503. CI pipelines that curl health endpoints repeat the same stack (what is CI/CD).
Remember the design traits MDN highlights
HTTP is designed to be simple and extensible via headers [1]. It is stateless at the core; cookies and tokens add session state when sites need it [1]. It expects a reliable transport, typically TCP [1] [2].
Caching, authentication, and content negotiation are all header-driven contracts [1]. That is why reverse proxies can cache GET responses or strip sensitive headers without changing application code.
Status codes you will see in logs
RFC 9110 groups statuses by class [2]:
| Range | Meaning | Examples |
|---|---|---|
| 1xx | Informational | 100 Continue (expect/continue flows) |
| 2xx | Success | 200 OK, 204 No Content |
| 3xx | Redirection | 301 Moved Permanently, 304 Not Modified |
| 4xx | Client error | 400 Bad Request, 404 Not Found, 429 Too Many Requests |
| 5xx | Server error | 502 Bad Gateway, 503 Service Unavailable |
304 is not an error: it tells the client to use a cached representation when validators match. 503 with Retry-After is a capacity signal, not necessarily a code bug.
Methods at a glance
Safe methods should not change server state when used as intended [2]. GET and HEAD are safe for retrieval. POST is unsafe and common for creates and actions. PUT and DELETE target resources with idempotency rules spelled out in RFC 9110. APIs document which method maps to which business operation (what is an API).
OPTIONS and TRACE appear in debugging and CORS preflight. Most application authors interact with GET, POST, PATCH, and DELETE daily.
Headers worth learning early
Host is required in HTTP/1.1 name-based virtual hosting [3]. Content-Type tells parsers how to decode the body. Cache-Control and ETag/If-None-Match drive conditional GETs that save bandwidth [1] [2]. Authorization carries bearer tokens or schemes; cookies ride in their own headers when sessions exist [1].
Mis-set Content-Type on JSON APIs produces clients that silently mis-parse. Mis-set Cache-Control on authenticated pages leaks private data through shared caches. Headers are contracts, not decoration.
Trace one curl verbosely (optional)
curl -svo /dev/null https://example.com 2>&1 | head -20stderr shows TLS negotiation and request headers curl sends; stdout would hold the body. Use this when a browser works but a script fails: compare Host, SNI, and redirects.
Proxies and intermediaries MDN names
MDN lists proxies that can cache, filter, load-balance, or terminate TLS [1]. Corporate proxies may rewrite headers. CDNs may serve stale assets when Cache-Control allows. None of that changes HTTP semantics at the origin; it adds actors between client and server. Debug with curl -v from the same network path your app uses.
Bodies and transfer encodings
Small JSON APIs often send a known Content-Length. Streaming responses may use chunked transfer encoding so the server need not know the final size upfront [3]. HTTP/2 frames bodies differently but still ends in bytes the client reassembles. Size mismatches and truncated downloads show up as parser errors or incomplete JSON, not always as HTTP error statuses.
Connection reuse and keep-alive
HTTP/1.1 defaults to persistent connections unless either side closes [3]. Clients reuse TCP sessions for many requests to the same host, which is why one HTML page triggers parallel connections or multiplexed HTTP/2 streams instead of one serial connection per asset [1]. Connection errors mid-page show as partial loads even when the first request returned 200.
Failure modes worth naming
Equating HTTP with HTML. HTTP is the envelope; HTML, JSON, and images are bodies.
One request equals one page. Modern pages trigger dozens of parallel requests. Performance work counts waterfalls, not only the first document [1].
Treating all 4xx/5xx as "server down." 404 is often a routing mistake. 401/403 are auth. 429 is rate limits. 502/503 are upstream or capacity. Read the status and body.
Ignoring idempotency on POST. Retrying payments or creates can duplicate side effects. HTTP semantics distinguish safe methods from unsafe ones [2].
Confusing HTTP/2 with WebSockets. HTTP/2 is still request-response multiplexed on TCP. WebSockets upgrade to a different full-duplex channel.
Save one raw request and response pair from curl -v the next time a service fails. Name lookup from how DNS works and the process behind what is a server narrow which layer broke; what is an API is where methods and status codes become product contracts instead of wire trivia. For how libraries and frameworks sit on top of those requests, see framework vs library.
Send this to the friend who says HTTP when they mean the whole browser stack.

Keep this guide
Filed under Dev explainers
Questions about this guide
Is HTTP the same as the internet?
No. HTTP is an application-layer protocol for fetching and modifying resources. It usually rides on TCP (port 80 cleartext, 443 with TLS). IP routing and DNS sit below; HTML or JSON in the body are payloads HTTP carries, not HTTP itself.
What is a request versus a response?
Clients send requests: method, target path or URL, HTTP version, headers, optional body. Servers answer with responses: status code, reason phrase, headers, optional body. Both sides can send headers that control caching, auth, and content type.
Is HTTP stateful?
MDN: the core protocol is stateless between requests. Sites add sessions with cookies, bearer tokens, or server-side stores. Stateless transport does not mean your bank account forgets you; it means each request must carry whatever context the server needs.
Does HTTP/2 change the mental model?
HTTP/2 multiplexes many requests on one TCP connection and uses binary framing. You still think in methods, status codes, and headers. Tools like curl abstract framing; packet captures look different from HTTP/1.1 text.
Sources
- MDN: Overview of HTTP, accessed 2026-12-03developer.mozilla.org
- RFC 9110: HTTP Semantics, accessed 2026-12-03rfc-editor.org
- RFC 9112: HTTP/1.1, accessed 2026-12-03rfc-editor.org
- Full Byte Developer: What is an APIfullbytedeveloper.com
- Full Byte Developer: What is CI/CDfullbytedeveloper.com
- Full Byte Developer: What is a serverfullbytedeveloper.com
- Full Byte Developer: How DNS worksfullbytedeveloper.com