http, one header per page
Twenty-eight lessons on what HTTP headers are: the text lines above every body, a name, a colon and a value, ending at a blank line; the law of one header per page; Host and User-Agent, the server's name and the client's; Accept and Content-Type; Accept-Encoding and Content-Encoding, with a gzip body of 61 bytes; Authorization with its 401 then 200, Cookie, Set-Cookie and Origin; Cache-Control, ETag, If-None-Match with its 304, and Vary; Location with its 302 and 301, Range with its 206, Content-Length and Forwarded; the browser's guardrails, CSP, HSTS, X-Frame-Options and Referrer-Policy; CORS, Connection, Last-Modified, and one honest hour.
One header, one page, one real exchange. That is the shape of this book.
http, one header per page
Twenty-eight lessons on what HTTP headers are: the text lines above every body, a name, a colon and a value, ending at a blank line; the law of one header per page; Host and User-Agent, the server's name and the client's; Accept and Content-Type; Accept-Encoding and Content-Encoding, with a gzip body of 61 bytes; Authorization with its 401 then 200, Cookie, Set-Cookie and Origin; Cache-Control, ETag, If-None-Match with its 304, and Vary; Location with its 302 and 301, Range with its 206, Content-Length and Forwarded; the browser's guardrails, CSP, HSTS, X-Frame-Options and Referrer-Policy; CORS, Connection, Last-Modified, and one honest hour.
Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).
An honest book about its demos: the demo server was Python's http.server module (Python 3.14.9) on the build machine, loopback only (127.0.0.1:8185); the clients were curl 8.5.0 and Python 3.14.9 http.client. Every quoted line was captured from those real runs inside /root/.hermes/cache/scratch/httpdemo185/, nothing outside it written. No output was invented. No browser, no HTTP/2 or HTTP/3 exchange, no public server. Every other fact traces to the MDN Web Docs header reference pages and the cached Wikipedia articles; no facts from Reddit, Stack Overflow, vendor blogs or commercial sites. Every practice exercise carries 'this book's plan'. Independent, not affiliated with Mozilla, the Internet Engineering Task Force or the Wikimedia Foundation.
Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.
© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.
Edition 1.0 · stevehodgkiss.net
Contents
Per the Wikipedia List of HTTP header fields article, The user agent string of the user agent. Per the Wikipedia HTTP article, A web browser is an example of a user agent (UA). Per a real loopback run captured at dispatch, > User-Agent: curl/8.5.0; User-Agent: curl/8.5.0; SENT 'User-Agent: raw-socket/185'; $ python3 client185.py; STATUS: 200; BODY: hello header book. Per the demo client script, 'User-Agent': 'book-demo/1.0'.
User-Agent
Per the list, User-Agent carries the user agent string of the user agent; a browser is one, and so is curl.
Three clients, three names: curl sent User-Agent: curl/8.5.0, the raw socket sent User-Agent: raw-socket/185, and the Python client script asked for 'User-Agent': 'book-demo/1.0'.
The server may read it, log it or ignore it; here it only echoed it back.
What does your own client call itself, and would you want a server to know?
Per the MDN Web Docs Accept-Encoding header reference, The HTTP Accept-Encoding request and response header indicates the content encoding (usually a compression algorithm) that the sender can understand; In requests, the server uses content negotiation to select one of the encoding proposals from the client and informs the client of that choice with the Content-Encoding response header; identity: Indicates the identity function (that is, without modification or compression). This value is always considered as acceptable, even if omitted. Per the Wikipedia HTTP compression article, The web client advertises which compression schemes it supports by including a list of tokens in the HTTP request. Per a real loopback run captured at dispatch, curl -sv --compressed http://127.0.0.1:8185/; > Accept-Encoding: deflate, gzip, br, zstd; < Content-Type: text/plain. Per the demo client script, 'Accept-Encoding': 'identity'.
Accept-Encoding
Per the MDN Web Docs Accept-Encoding header reference, it indicates the content encoding (usually a compression algorithm) that the sender can understand.
Here curl's --compressed sent Accept-Encoding: deflate, gzip, br, zstd and the first server sent no Content-Encoding back; the Python client script asked for 'Accept-Encoding': 'identity', which is always considered as acceptable, even if omitted.
Ask for what you can decode: the server picks one, or sends the body plain.
Which encodings can your own client really decode, and which do you list anyway?
Per the MDN Web Docs Origin header reference, The HTTP Origin request header indicates the origin (scheme, hostname, and port) that caused the request; The Origin header is similar to the Referer header, but does not disclose the path, and may be null. Per the Wikipedia Same-origin policy article, An origin is defined as a combination of URI scheme, host name, and port number. Per the Wikipedia HTTP referer article, is an optional HTTP header field that identifies the address of the web page (i.e., the URI or IRI) from which the resource has been requested. Per a real loopback run captured at dispatch, > Origin: https://example.test; < Access-Control-Allow-Origin: https://example.test; cross-origin hello; > Referer: http://example.test/page; > Origin: http://example.test.
Origin
Per the MDN Web Docs Origin header reference, it indicates the origin (scheme, hostname, and port) that caused the request; it is similar to the Referer header, but does not disclose the path.
Here Origin: https://example.test was answered Access-Control-Allow-Origin: https://example.test and cross-origin hello, while Referer: http://example.test/page gave away a path too.
Per the same-origin article, an origin is a combination of URI scheme, host name, and port number.
Which origin would your own pages announce, and what would rather stay hidden?
Per the MDN Web Docs Vary header reference, The HTTP Vary response header describes the parts of the request message (aside from the method and URL) that influenced the content of the response it occurs in; Including a Vary header ensures that responses are separately cached based on the headers listed in the Vary field; The same Vary header value should be used on all responses for a given URL, including 304 Not Modified responses and the "default" response. Per a real loopback run captured at dispatch, < Vary: Accept-Encoding; < Content-Encoding: gzip; < Vary: Origin; < Access-Control-Allow-Origin: https://example.test; Vary: Accept-Encoding; Vary: Origin.
Vary
Per the MDN Web Docs Vary header reference, it describes the parts of the request message (aside from the method and URL) that influenced the content of the response it occurs in, so responses are separately cached based on the headers listed in the Vary field.
Two real lines: Vary: Accept-Encoding on /gzip, whose body depended on the encoding offered, and Vary: Origin on /cors, whose answer named the asking origin.
The same value on every response for a URL, including 304 Not Modified responses.
Which request header changes what your own server sends, and does your cache know?
Per the MDN Web Docs Forwarded header reference, The HTTP Forwarded request header contains information that may be added by reverse proxy servers (load balancers, CDNs, etc.) that would otherwise be altered or lost when proxy servers are involved in the path of the request; The header is optional and may be added to, modified, or removed, by any of the proxy servers on the path to the server; The alternative and de-facto standard versions of this header are the X-Forwarded-For , X-Forwarded-Host and X-Forwarded-Proto headers. Per the MDN Web Docs X-Forwarded-For header reference, If any proxy is malicious or misconfigured, any part of the header not added by a trusted proxy may be spoofed or may have an unexpected format or contents. Per the MDN Web Docs Via header reference, The Via request and response header is added by proxies , both forward and reverse. Per a real loopback run captured at dispatch, > X-Forwarded-For: 203.0.113.185; > Forwarded: for=203.0.113.185;host=demo.local;proto=https; X-Forwarded-For: 203.0.113.185; < Via: 1.1 demo-proxy-185.
Forwarded
Per the MDN Web Docs Forwarded header reference, it contains information that may be added by reverse proxy servers, and may be added to, modified, or removed, by any of the proxy servers on the path.
Here curl wrote X-Forwarded-For: 203.0.113.185 and Forwarded: for=203.0.113.185;host=demo.local;proto=https itself, no proxy in front; on /proxied the answer carried Via: 1.1 demo-proxy-185.
Per the X-Forwarded-For reference, any part of the header not added by a trusted proxy may be spoofed.
Which address in your logs is only a proxy's claim?
Per the Wikipedia HTTP Strict Transport Security article, HTTP Strict Transport Security (HSTS) is a policy mechanism that helps to protect websites against man-in-the-middle attacks such as protocol downgrade attacks and cookie hijacking; The HSTS Policy is communicated by the server to the user agent via an HTTP response header field named Strict-Transport-Security; A server implements an HSTS policy by supplying a header over an HTTPS connection (HSTS headers over HTTP are ignored); 31,536,000 is equal to one non-leap year. Per the Wikipedia List of HTTP header fields article, A HSTS Policy informing the HTTP client how long to cache the HTTPS-only policy and whether this applies to subdomains. Per a real loopback run captured at dispatch, Strict-Transport-Security: max-age=31536000; includeSubDomains.
The HSTS header
Per the Wikipedia HTTP Strict Transport Security article, HSTS is a policy mechanism that helps to protect websites against man-in-the-middle attacks such as protocol downgrade attacks and cookie hijacking.
Here the header read Strict-Transport-Security: max-age=31536000; includeSubDomains: 31,536,000 is equal to one non-leap year, and subdomains are included.
One honest limit: HSTS headers over HTTP are ignored, and this loopback run was plain HTTP, so no browser kept the promise.
Which of your sites could promise HTTPS for a year starting today?
Per this book's plan, one honest hour of practice is: start the demo server script, run curl -sv http://127.0.0.1:8185/ and read the three request lines and the blank line, then curl -sI http://127.0.0.1:8185/, ask for a slice with curl -sv -H "Range: bytes=6-" http://127.0.0.1:8185/, ask for a 304 with curl -sv -H "If-None-Match: \"demo-etag-185\"" http://127.0.0.1:8185/, then python3 rawget185.py /cookie, python3 rawget185.py /etag, python3 rawget185.py /security, python3 rawget185.py /cors and python3 rawget185.py /auth, and follow a redirect with curl --max-time 8 -sIL http://127.0.0.1:8185/redirect; every one of these commands ran on the build machine inside the scratch directory /root/.hermes/cache/scratch/httpdemo185/, and nothing outside it was written.
One honest hour
Per this book's plan, one honest hour: start the demo server script, then curl -sv http://127.0.0.1:8185/ and read the three request lines and the blank line that ends them.
Then in order: curl -sI http://127.0.0.1:8185/, Range: bytes=6-, If-None-Match: "demo-etag-185", python3 rawget185.py /cookie, /etag, /security, /cors, /auth, then curl --max-time 8 -sIL http://127.0.0.1:8185/redirect.
One hour on loopback: every line you see, you can also read in the logs.
Book the hour this week; which header will surprise you most?