Networking handbook · Chapter 13

HTTP and HTTPS

A web request asks an origin to perform a method on a resource. HTTPS preserves those HTTP semantics while securing the connection to the origin. Reading the URL, method, headers and status together explains what the browser requested and which answer it received.

In this guide13 sections

Introduction

A web request asks an origin to perform a method on a resource. HTTPS preserves those HTTP semantics while securing the connection to the origin. Reading the URL, method, headers and status together explains what the browser requested and which answer it received.

Identify a resource and an origin

In https://docs.example/charts/latest?unit=ms the scheme is https, the host is docs.example, the path is /charts/latest and the query is unit=ms. With no explicit port the scheme implies 443. The scheme, host and effective port determine the origin. Paths and queries distinguish resources within it.

GET asks for a representation, HEAD asks for the response metadata of a corresponding GET without response content, and POST asks the target to process submitted content according to that resource’s semantics. A method and a status code carry more meaning together than either does in isolation.

Read a response in context

The status code describes the outcome of handling the request. Header fields qualify it. Content-Type describes the media type, Location can identify a redirection destination, and ETag can label a selected representation for cache validation.

A cache holding a representation and its ETag can send If-None-Match on a later GET. When the validator still matches, the server can reply 304 and omit the representation body. The cache then reuses its stored representation under the HTTP caching rules.

Distinguish semantics from transport

HTTP/1.1 and HTTP/2 commonly run on TCP. For HTTPS with these versions, TLS authenticates the origin and protects HTTP data on the connection. HTTP/3 maps the same core semantics onto QUIC streams, with QUIC using UDP and integrating TLS 1.3.

A reverse proxy can terminate the public TLS connection and open a separate upstream connection. Document the protocol used on each leg. A response status by itself cannot establish whether it came from the origin application or an intermediary.

Diagram

  1. Browser selects origin
  2. Secure connection to docs.example
  3. GET /charts/latest
  4. 200 and representation
The route from request to representation for a fresh fetch. Connection reuse and caching can omit steps on later requests.

Worked examples

Revalidate a cached chart

  1. Suppose a GET for /charts/latest returns 200, Content-Type: image/png and ETag: "chart-7". Store the body and validator together.
  2. Later, send a conditional GET for the same representation with If-None-Match: "chart-7" when validation is required.
  3. If the representation still matches, a 304 response allows reuse of the stored chart. If it changed, a 200 response can supply the new content and validator.

TCP/UDP Port Reference: Read a DNS resolver configuration

  1. A resolver configuration lists DNS on port 53. Look up 53 and consider both UDP and TCP.
  2. For a conventional UDP query, model the client as sending from a temporary port to destination UDP 53. The response reverses those endpoints.
  3. A TCP exchange with the same DNS service uses TCP 53. Record the transport explicitly when describing the two cases.

Reference table

HTTP and HTTPS reference
ResponseTypical meaningWhat to inspect
200 OKRequest succeededMethod, representation and headers
304 Not ModifiedCached representation can be reusedRequest validator and stored response
404 Not FoundNo current representation disclosed for this targetRequested path and routing
503 Service UnavailableTemporary inability to handle the requestRetry-After if supplied

Configuration example

  • For docs.example, record the public HTTPS origin, certificate name and upstream service separately. Route /charts/ to the intended application and preserve the requested authority as required by the proxy configuration.
  • For a cacheable chart, set a documented freshness policy and choose a validator that changes when its selected representation changes. Different language or encoding variants may require separate cache entries.

Common mistakes

  • Concluding that an HTTP 404 means a DNS lookup failed. An HTTP response was produced by some HTTP endpoint.
  • Assuming the HTTPS scheme specifies HTTP/2. HTTP versions are negotiated or selected separately.

Frequently asked questions

Does HTTPS require TCP 443?

443 is the default port for the scheme. An explicit port can override it. HTTP/3 commonly uses UDP 443 through QUIC.

Does 304 mean the server sent an empty file?

It answers a conditional request. The client already has the representation and uses the 304 metadata to update its cached response.

Does HTTPS change the HTTP request model?

HTTP remains the application protocol. HTTPS carries HTTP over a protected TLS connection, adding confidentiality, integrity, and server authentication when correctly configured.

Does a lock icon guarantee that a website is trustworthy?

No. It indicates a protected connection to the named site when certificate validation succeeds. It does not verify the site's honesty, content, or business practices.

Can HTTP use a port other than 80 or HTTPS other than 443?

Yes. Those are common defaults, not exclusive assignments. A URL can specify another port, and a server can be configured to listen elsewhere.

Why can a successful TCP connection still fail to load a page?

TLS negotiation, certificate checks, HTTP routing, authentication, application errors, or content loading may still fail after transport connectivity is established.

What does an HTTP status code describe?

It summarizes the server's handling of a request, such as success, redirection, client error, or server error. The response body and application-specific context provide further detail.

Does HTTPS hide the destination hostname from every observer?

TLS protects HTTP content, but DNS queries and some connection metadata can still reveal destination information. Encrypted DNS and newer TLS features have their own deployment and privacy limits.

Why does HTTP use methods such as GET and POST?

Methods describe the intended semantics of a request. Servers and intermediaries use them when applying caching, safety, routing, and application behavior.

Can an HTTP redirect change the security of a visit?

Yes. A redirect sends the client to another URL, potentially another host. Review the final destination and rely on browser protections rather than assuming the original link controls the destination.

What does idempotent mean for an HTTP method?

An idempotent method has the same intended effect when repeated, even if each request can return a different response. This matters for safe retries and cache behavior.

What is an HTTP cache validator?

A validator such as an entity tag or modification time lets a client ask whether a cached representation is still current, potentially avoiding a full body transfer.

Are cookies part of the HTTP protocol?

Cookies are HTTP headers and browser storage behavior used by applications to carry state. Their security depends on attributes, scope, transport protection, and application design.

Does a 404 response mean the server is offline?

No. It indicates that the server or application did not find the requested resource at that path. The host and HTTP service may be reachable even when one URL is absent.

Can HTTPS protect content from the website operator?

No. HTTPS protects data in transit between the client and the server endpoint. The server that terminates TLS can generally process the HTTP request and response.

Further learning and references