← All 185 books http, one header per page
One header per page

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.


Steve Hodgkiss 7 lessons

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

Contents


Part 1 · The envelope
User-Agent4
Part 2 · Asking and answering
Accept-Encoding5
Part 3 · Identity and origin
Origin6
Part 4 · Keeping a copy
Vary7
Part 5 · Moving and routing
Forwarded8
Part 6 · The browser's guardrails
The HSTS header9
Part 7 · Cross-origin and the honest hour
One honest hour10

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'.

http companion · No. 01
the caller

User-Agent

what the client calls itself

User-Agent: whatever the client calls itself, sent with every requestcurl 8.5.0User-Agent: curl/8.5.0the raw socket scriptUser-Agent: raw-socket/185the Python client script'User-Agent': 'book-demo/1.0'the demo server, echoing what it receivedUser-Agent: curl/8.5.0Accept: */*echoed in the body,not read for a decisionbody-bytes: 0a name the client chooses; the server may believe it or not

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.

ONE HONEST EXCHANGE

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'.

http companion · No. 02
the encoding ask

Accept-Encoding

which codings the client can undo

Accept-Encoding: the codings the client can undo, the server picks oneAccept-Encoding: deflate, gzip, br, zstddeflategzipbrzstdfour names offered; identity is always acceptablethe first server, no Content-EncodingContent-Type: text/plain{ [18 bytes data]the Python client script asked:'Accept-Encoding': 'identity'curl -sv --compressed http://127.0.0.1:8185/hello header bookask for what you can decode; the server answers with the one it used

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.

ONE HONEST EXCHANGE

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.

http companion · No. 03
the where from

Origin

which origin caused the request

Origin: the scheme and host that caused the request, never the paththe page the request came fromhttp://example.test/pageReferer: http://example.test/pagewith the pathorigin onlyOrigin: https://example.testAccess-Control-Allow-Origin: https://example.test$ curl --max-time 8 -sv -H 'Origin: https://example.test' http://127.0.0.1:8185/corscross-origin hellothe reply the browser may now hand to the other originOrigin names where a request was born; Referer also tells the page

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.

ONE HONEST EXCHANGE

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.

http companion · No. 04
the cache key

Vary

which request headers changed the answer

Vary: the request headers that changed the answer split the cacheAccept-Encoding: deflate, gzip, br, zstdOrigin: https://example.testone cache,two entriesper URLVary: Accept-EncodingContent-Encoding: gzipVary: OriginAccess-Control-Allow-Origin: https://example.test$ curl --max-time 8 -sv --compressed http://127.0.0.1:8185/gzipVary: Accept-EncodingVary: Originthe same Vary on every response for a URL, the 304 included

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.

ONE HONEST EXCHANGE

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.

http companion · No. 05
the path behind a proxy

Forwarded

who a proxy says was really asking

Forwarded: what a proxy adds about the client; here the client wrote it itselfcurl, no proxy in frontX-Forwarded-For: 203.0.113.185Forwarded: for=203.0.113.185;host=demo.local;proto=httpsa claim, not a fact:nothing on the path added itthe demo serverVia: 1.1 demo-proxy-185X-Forwarded-For: 203.0.113.185Forwarded: for=203.0.113.185;host=demo.local;proto=httpstrust only the part a proxy you control added; Via names the proxy itself

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.

ONE HONEST EXCHANGE

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.

http companion · No. 06
the HTTPS promise

The HSTS header

remember: this site is HTTPS only

Strict-Transport-Security: a promise in seconds, kept only over HTTPSthe demo serverStrict-Transport-Security: max-age=31536000; includeSubDomainsmax-age, in seconds:one non-leap yearincludeSubDomains:subdomains included toothe same header over HTTPis ignored by the browser;this loopback run was plain HTTPStrict-Transport-Security: max-age=31536000; includeSubDomainsa promise the user agent remembers,not something the server can checkHSTS is the header's job name; the field is Strict-Transport-Security

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.

ONE HONEST EXCHANGE

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.

http companion · No. 07
the handoff

One honest hour

a practice plan, labeled as such

one honest hour: eight moves on loopback, planned and labeled1see the request linescurl -sv http://127.0.0.1:8185/2headers onlycurl -sI http://127.0.0.1:8185/3ask for a sliceRange: bytes=6-4earn a 304If-None-Match: "demo-etag-185"5read the raw cookie linespython3 rawget185.py /cookie6etag, security, cors, authpython3 rawget185.py /etag7follow a redirectLocation: /echo8ask for credentials-u demo:s185this book's plan: every command ran here on 127.0.0.1:8185, every line is in the logsone hour on loopback: see the lines, read them back, throw nothing away

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.

ONE HONEST EXCHANGE

Book the hour this week; which header will surprise you most?

Index

Index


Accept-Encoding5
Forwarded8
One honest hour10
Origin6
The HSTS header9
User-Agent4
Vary7