HTTP & HTTPS — How the Web Works

HTTP-HTTPS

How browsers and servers exchange resources using HTTP request/response cycles, what every status code category means, and why HTTPS is a fundamentally different security model — not just HTTP with encryption bolted on.

applicationhttphttpsrequestresponsestatus-codeswebrfc9110

Overview

Every time a browser loads a web page, it speaks HTTP — Hypertext Transfer Protocol. HTTP is the language of the web: a simple, text-based request/response protocol where a client asks for a resource and a server responds with it. It is stateless (each request is independent), extensible (headers carry arbitrary metadata), and human-readable in its original form.

HTTPS is HTTP transported over a TLS (Transport Layer Security) connection. The HTTP messages themselves are identical — the same request format, the same response format, the same status codes. What changes is that TLS encrypts and authenticates the connection before any HTTP traffic flows. HTTPS is not a different protocol; it is HTTP with a security layer underneath it.

HTTP is defined across a family of RFCs. The current authoritative specification is RFC 9110 (HTTP Semantics), RFC 9111 (HTTP Caching), and RFC 9112 (HTTP/1.1). HTTP/2 is defined in RFC 9113; HTTP/3 in RFC 9114.


The Request/Response Model

HTTP is fundamentally a client-server protocol. The client (browser, curl, API consumer) sends a request; the server processes it and sends a response. There is no server-initiated communication in plain HTTP — the server can only respond to requests.

Browser
Web Server
HTTP Request
GET /index.html HTTP/1.1
HTTP Response
200 OK — Content-Type: text/html
HTTP Request
GET /style.css HTTP/1.1
HTTP Response
200 OK — Content-Type: text/css

HTTP Request Format

An HTTP/1.1 request is plain text:

GET /school/layer3/dhcp HTTP/1.1
Host: nakamas-it.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

Request Line: METHOD path HTTP/version

Methods (the most important):

MethodPurposeBody?Safe?Idempotent?
GETRetrieve a resourceNoYesYes
POSTSubmit data, create a resourceYesNoNo
PUTReplace a resource entirelyYesNoYes
PATCHPartially update a resourceYesNoNo
DELETERemove a resourceOptionalNoYes
HEADSame as GET but no body returnedNoYesYes
OPTIONSAsk server what methods are allowedNoYesYes

Safe means the method does not modify server state. Idempotent means calling it multiple times produces the same result as calling it once (important for retries).

Headers: Key-value pairs carrying metadata. Critical ones:


HTTP Response Format

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 8492
Cache-Control: max-age=3600
ETag: "abc123def456"
Date: Sat, 08 Mar 2026 07:00:00 GMT

<!doctype html>
<html>...

Status Line: HTTP/version STATUS_CODE Reason-Phrase

Status Code Categories

RangeCategoryMeaning
1xxInformationalRequest received, continuing process
2xxSuccessRequest successfully received and processed
3xxRedirectionFurther action needed to complete request
4xxClient ErrorRequest contains bad syntax or cannot be fulfilled
5xxServer ErrorServer failed to fulfil a valid request

The codes every sysadmin knows:

CodeNameCommon Cause
200OKSuccess
201CreatedResource created (POST/PUT response)
204No ContentSuccess, no body (DELETE response)
301Moved PermanentlyURL changed forever — clients should update bookmarks
302FoundTemporary redirect
304Not ModifiedCached version is still valid — no body sent
400Bad RequestMalformed request syntax
401UnauthorizedAuthentication required
403ForbiddenAuthenticated but not authorized
404Not FoundResource does not exist
405Method Not AllowedServer understands the URL but not the method
429Too Many RequestsRate limit exceeded
500Internal Server ErrorSomething broke on the server
502Bad GatewayProxy received invalid response from upstream
503Service UnavailableServer temporarily unable to handle requests
504Gateway TimeoutProxy timed out waiting for upstream

HTTP Versions

HTTP/1.1 (1997 — RFC 9112)

The long-lived workhorse. Text-based, human-readable. One request per TCP connection (or pipelined, but pipelining was never widely used due to head-of-line blocking). Keep-Alive allows reusing TCP connections across multiple requests.

Limitation: each response must complete before the next request can begin on the same connection (head-of-line blocking). Browsers work around this by opening 6 parallel TCP connections per host.

HTTP/2 (2015 — RFC 9113)

Binary framing, multiplexed streams over a single TCP connection. Multiple requests and responses interleave freely — no head-of-line blocking at the HTTP layer. Server push allows the server to proactively send resources the client will need. Header compression (HPACK). Requires TLS in practice (browsers only implement HTTP/2 over TLS).

HTTP/3 (2022 — RFC 9114)

HTTP/2 semantics over QUIC (UDP-based transport) instead of TCP. Eliminates TCP-level head-of-line blocking entirely. Built-in 0-RTT connection resumption. Connection migration (the session survives IP address changes, important for mobile).


What HTTPS Actually Does

HTTPS = HTTP over TLS. Before any HTTP request is sent, TLS establishes an encrypted, authenticated channel. This provides:

Confidentiality: All HTTP traffic — headers, body, URLs — is encrypted. An observer on the network sees only that a TLS connection was made to an IP address, not what was requested or returned.

Authentication: The server presents a TLS certificate signed by a trusted Certificate Authority (CA). The browser verifies the certificate is valid, not expired, and was issued for the domain being visited. This prevents impersonation — a fake server cannot present a valid certificate for nakamas-it.com unless it has the private key.

Integrity: TLS’s MAC (Message Authentication Code) ensures that data was not tampered with in transit. Every byte that arrives is verified to be exactly what the server sent.

What HTTPS does NOT guarantee: That the website is legitimate or trustworthy. A certificate proves the server is who it says it is — not that the entity behind it is honest. A phishing site at security-update-nakamas-it.com can have a perfectly valid HTTPS certificate.

The Mixed Content Problem

If an HTTPS page loads any resource (image, script, stylesheet) over plain HTTP, browsers block or warn about mixed content. A single HTTP image on an HTTPS page can allow a network attacker to inject content into what the user believes is a secure page. All subresources must be HTTPS for the security guarantee to hold.


Important HTTP Headers

Security Headers

HeaderPurpose
Strict-Transport-Security (HSTS)Tells browsers to always use HTTPS for this domain — never downgrade to HTTP
Content-Security-Policy (CSP)Restricts which sources scripts, styles, and images can load from
X-Frame-OptionsPrevents the page from being embedded in an iframe (clickjacking protection)
X-Content-Type-Options: nosniffPrevents browser MIME type sniffing
Referrer-PolicyControls how much referrer information is sent with requests

Caching Headers

HeaderPurpose
Cache-ControlDirectives for caching: max-age, no-cache, no-store, private, public
ETagA fingerprint of the resource version — used for conditional requests
Last-ModifiedWhen the resource was last changed
If-None-MatchClient sends the ETag — server returns 304 if unchanged

Key Concepts

HTTP is stateless — cookies provide state

Each HTTP request is completely independent. The server has no memory of previous requests. Cookies are the mechanism for maintaining state: the server sets a cookie in the response, and the browser sends it back with every subsequent request. Session IDs, authentication tokens, and user preferences are all stored in cookies.

401 vs 403 — know the difference

401 means the client is not authenticated — it needs to provide credentials. 403 means the client is authenticated but does not have permission. Returning 403 for unauthenticated users is technically incorrect (though common) and leaks information about whether a resource exists.


References