HTTP
Most important commands to remember
curl -i URL— request a resource and include response headers.curl -I URL— send HEAD to inspect metadata without a response body.
Commands and flags
| Option | Meaning |
|---|---|
-i |
Include headers alongside the downloaded body. |
-I |
Use the HTTP HEAD method, not GET with hidden output. |
--max-time 10 |
Limit each transfer to ten seconds. |
The examples request a public example domain over HTTPS, leaving certificate verification enabled.
The concepts that matter
1. A request expresses intent toward a resource
HTTP is an application protocol built around requests and responses. A request identifies a target and a method. GET retrieves a representation; HEAD asks for corresponding metadata without transferring the response content. Other methods express different intentions.
A URL identifies where to send the request and which resource to address. A resource is a conceptual target, not necessarily a physical file on disk. A server can generate its response dynamically.
2. Status describes the protocol outcome
Responses contain a status code. The broad classes are 2xx for success, 3xx for redirection, 4xx for client-side request problems, and 5xx for server-side failure handling. The precise code matters more than the class alone.
A 200 response means the HTTP request succeeded according to that endpoint. It does not automatically confirm every business action or dependency. A connection failure before a response has no HTTP status from the target server.
3. Headers describe how to interpret content
Headers carry metadata and controls. Content-Type describes the representation format. Content-Length, when present, describes a byte length under the message’s framing rules. Location can identify a redirect target.
The body carries content such as HTML, JSON, or binary data. Not every response has one. A HEAD response can advertise the length a GET representation would have while carrying no body, so header values must be interpreted with the method and status.
4. HTTP semantics and transport are separate layers
HTTP/1.1, HTTP/2, and HTTP/3 express related methods, statuses, and headers using different wire formats and transport arrangements. HTTPS adds a protected connection; it does not make every returned page trustworthy or every operation authorized.
Cookies, tokens, and server-side state let applications build sessions over HTTP exchanges. A command-line request also differs from a browser: curl does not automatically execute JavaScript or download every resource referenced by an HTML page.
One small example
Optional: run the two commands in a terminal with curl. They make a GET and then a HEAD request.
curl -i --max-time 10 https://example.com/
curl -I --max-time 10 https://example.com/
Compare status and headers before reading the GET body. The second response should have no body even if a Content-Length is present. The two responses need not have identical metadata if the resource or server handling changes.
Actual status, headers, protocol version, and content can vary. A redirect is not followed automatically here; inspect its Location instead. Curl can exit successfully after receiving an HTTP error status because successful transport is different from application success.
A timeout or TLS error may occur before any response. Nothing is installed or changed locally, and no cleanup is needed.
Keep this idea: Read method, status, headers, and body together; a completed transfer and a successful application action are different claims.