Speed

What a Loopback Recording Misses

One recording is one client, one scripted server, one second on one machine; it shows what was sent, not what other servers or networks do.

The question

The recording of this book is exact: every byte of nine requests and nine responses is there. What does that prove, and what can it never show? Take connection 4. The client curl 8.5.0 asked the scripted server lmmock 0.1.0 for /hello and added Accept-Encoding: gzip. Did the server compress its answer? And what else is missing from a capture that was made once, on 2026-11-21, between two programs on one machine?

Work it by hand

RFC 9110, section 12.5.3, says that Accept-Encoding in a request indicates the content codings acceptable in a response. Section 8.4 says that a sender that applied a coding MUST generate a Content-Encoding field.

Check the answer in three steps. First, read the request field: it says gzip. Second, look for Content-Encoding among the response fields: there is none. Third, read the body: five bytes, the letters of hello, not a gzip stream. So no coding was applied: the server ignored the offer. That is a fact about this script, and the request was still a correct one.

Run it

The demo reads the request and the response of connection 4 and puts the two fields side by side.

Two rows for connection 4 of the recording: asked for gzip, from the Accept-Encoding field of the request, and got identity (no Content-Encoding field), from the response; the response has 106 bytes.
let req = ssl.unhex(request);
let res = ssl.unhex(response);
let a = str_find(str_lower(req), "accept-encoding: ");
let b = str_find(str_lower(res), "content-encoding: ");
let asked = "nothing";
if (a >= 0) {
  let rest = str_substr(req, a + 17, str_len(req) - a - 17);
  asked = str_split(rest, "\r\n").at(0);
}
let got = "identity (no Content-Encoding field)";
if (b >= 0) {
  let rest = str_substr(res, b + 18, str_len(res) - b - 18);
  got = str_split(rest, "\r\n").at(0);
}
let answer = "asked for " + asked + ", got " + got;
lmcode_return_put("asked", asked);
lmcode_return_put("got", got);
lmcode_return_put("response_bytes", str_len(res));
{
  "answer": "asked for gzip, got identity (no Content-Encoding field)",
  "asked": "gzip",
  "got": "identity (no Content-Encoding field)",
  "response_bytes": 106
}

Lines 3 and 4 find the two fields, in lower case so that any spelling is found. Lines 5 to 9 read what was asked for and lines 10 to 14 what came back. Line 15 builds the answer. The table says asked for gzip, got identity (no Content-Encoding field), and the response has 106 bytes.

You can change both inputs. A request without the field shows "nothing" as the offer. A response that carries Content-Encoding: gzip shows gzip (measured with a constructed field; the response then has 130 bytes). A field written in lower case is found too. The program never decodes a body: it only reads two fields. The search is for the text itself, so a field named X-Accept-Encoding is read as the offer too (measured: br).

Your turn

The program below should list the field names of a response in order. Several candidate programs are offered. Read them, run them on responses of your own, and decide which of them is right for every response. Some responses in the cases are recorded and some are constructed; the picture says which.

A recorded response of 176 bytes whose first bytes are 48 54 54 50 (HTTP), the list of field names that the shown program returns, and the number of field lines it found, 4.
let text = ssl.unhex(response);
let cut = str_find(text, "\r\n\r\n");
let head = str_split(str_substr(text, 0, cut), "\r\n");
let answer = str_list();
for (i in range(1, head.len())) {
  let name = str_split(head.at(i), ":").at(0);
  answer.add(name);
}
lmcode_return_put("field_lines", head.len() - 1);
{
  "answer": [
    "Content-Type",
    "X-Content-Type-Options",
    "Date",
    "Content-Length"
  ],
  "field_lines": 4
}

Return the names of the field lines of the response in the hex input response, in the order in which they appear, each in lower case, as a list of texts. A field line is a line of the head after the status line; its name is the text before the first colon. A name that appears twice is listed twice. Check runs your program on this response and on five others.

Read the result carefully

The recording is one second of one client talking to one script over loopback. It has no TLS, no name lookup (the host name www.example.test was set with --connect-to), no intermediary other than the witness that wrote the bytes down, no cache and no state kept between connections. The Date field is the clock of that moment, Sat, 21 Nov 2026 14:35:35 GMT, and no lesson computes with it.

Nothing was edited: the proxy forwarded every byte (stated in the fixture's recording.txt, not run here). The 404 and the 400 texts come from the server program's own HTTP code, not from the script.

In connection 8 a request without a Host field got a 400 whose reason phrase says what was missing; RFC 9112, section 3.2, says a server MUST answer an HTTP/1.1 request that lacks Host with 400, and this is what this server did, not what every server does. For cache fields see Cache Validator Skips the Body.

Recap

  • A recording shows what one client and one server sent, byte for byte, once.
  • The server ignored Accept-Encoding: gzip; the response had no Content-Encoding field.
  • No TLS, no real name lookup, no intermediary, no cache: say so where a claim needs it.
  • The client is curl 8.5.0, the server a script, the date 2026-11-21.