← tests

headers

The request header map at five headers and at thirty, left unread and with three of them bound and echoed.

Comparable across every framework. The unread rows hold the count, so the bound rows minus them is the binding rather than the materialising.

A value written {run.name} is drawn once per run and never given to the framework, so it cannot answer from a table.

testheftrequestbasewhat differs from the base
headers.few1GET /headers
headers.bind_few1GET /headers/bindheaders.fewthree request headers bound through the framework, one of them as an integer, and echoed in the response
headers.bind_many2GET /headers/bindheaders.bind_fewthirty request headers instead of five
headers.many2GET /headersheaders.fewthirty request headers instead of five

headers.few

heft 1

base of headers.bind_few, headers.many

Five request headers, none of which the handler reads. Two of the five are what an HTTP client adds itself, and the other three are the ones the binding rows bind. This is what headers.many is subtracted from.

Request

GET /headers
x-rb-tenant{run.tenant}
x-rb-request-id{run.requestId}
x-rb-account{run.account}

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}]}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/headers/few.ts
tests/headers/few.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";

const path = "/headers";

export default performanceTest({
  id: { family: "headers", name: "few" },
  path,
  heft: 1,
  about:
    "Five request headers, none of which the handler reads. Two of the five " +
    "are what an HTTP client adds itself, and the other three are the ones " +
    "the binding rows bind. This is what headers.many is subtracted from.",

  request: (c) =>
    c
      .get(path)
      .header("x-rb-tenant", c.run.tenant)
      .header("x-rb-request-id", c.run.requestId)
      .header("x-rb-account", String(c.run.account))
      .okWith(items.small),
});

headers.bind_few

heft 1

base headers.fewbase of headers.bind_many

The same five headers with three of them bound through the framework and written back, one as an integer. Read against headers.few, the difference is the binding rather than the materialising.

Request

GET /headers/bind
x-rb-tenant{run.tenant}
x-rb-request-id{run.requestId}
x-rb-account{run.account}

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}],"echo":{"tenant":"{run.tenant}","requestId":"{run.requestId}","account":{run.account}}}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/headers/bind-few.ts
tests/headers/bind-few.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";

const path = "/headers/bind";

export default performanceTest({
  id: { family: "headers", name: "bind_few" },
  path,
  base: "headers.few",
  varies: "header_binding",
  heft: 1,
  about:
    "The same five headers with three of them bound through the framework and " +
    "written back, one as an integer. Read against headers.few, the " +
    "difference is the binding rather than the materialising.",

  request: (c) =>
    c
      .get(path)
      .header("x-rb-tenant", c.run.tenant)
      .header("x-rb-request-id", c.run.requestId)
      .header("x-rb-account", String(c.run.account))
      .okWith(items.small, { echo: ["tenant", "requestId", "account"] }),
});

headers.bind_many

heft 2

base headers.bind_few

Three headers bound out of thirty instead of out of five. Read against headers.bind_few, the difference is whether a framework's binder pays for the headers it was not asked about.

Request

GET /headers/bind
x-rb-tenant{run.tenant}
x-rb-request-id{run.requestId}
x-rb-account{run.account}
x-rb-user-agentMozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0
x-rb-acceptapplication/json, text/plain, */*
x-rb-accept-languageen-US,en;q=0.5
x-rb-accept-encodinggzip, deflate, br, zstd
x-rb-refererhttps://shop.example.com/orders?page=2
x-rb-originhttps://shop.example.com
x-rb-sec-fetch-destempty
x-rb-sec-fetch-modecors
x-rb-sec-fetch-sitesame-origin
x-rb-priorityu=4
x-rb-pragmano-cache
x-rb-cache-controlno-cache
x-rb-tetrailers
x-rb-dnt1
x-rb-sec-gpc1
x-rb-forwarded-for203.0.113.195, 198.51.100.17
x-rb-forwarded-protohttps
x-rb-forwarded-hostshop.example.com
x-rb-forwarded-port443
x-rb-real-ip203.0.113.195
x-rb-via1.1 cdn-edge, 1.1 envoy
x-rb-traceparent00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
x-rb-tracestaterojo=00f067aa0ba902b7,congo=t61rcWkgMzE
x-rb-envoy-attempt-count1
x-rb-amzn-trace-idRoot=1-66e9b7c2-5759e988bd862e3fe1be46a9

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}],"echo":{"tenant":"{run.tenant}","requestId":"{run.requestId}","account":{run.account}}}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/headers/bind-many.ts
tests/headers/bind-many.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";
import { BROWSER_AND_PROXY } from "#models/fixture";

const path = "/headers/bind";

export default performanceTest({
  id: { family: "headers", name: "bind_many" },
  path,
  base: "headers.bind_few",
  varies: "header_count",
  heft: 2,
  about:
    "Three headers bound out of thirty instead of out of five. Read against " +
    "headers.bind_few, the difference is whether a framework's binder pays " +
    "for the headers it was not asked about.",

  request: (c) => {
    let call = c
      .get(path)
      .header("x-rb-tenant", c.run.tenant)
      .header("x-rb-request-id", c.run.requestId)
      .header("x-rb-account", String(c.run.account));

    for (const [name, value] of BROWSER_AND_PROXY) call = call.header(name, value);

    return call.okWith(items.small, { echo: ["tenant", "requestId", "account"] });
  },
});

headers.many

heft 2

base headers.few

Thirty request headers, still read by nothing. Read against headers.few, the difference is the cost of materialising twenty-five more that nobody asked for, which is about a kilobyte and close to what a real request carries.

Request

GET /headers
x-rb-tenant{run.tenant}
x-rb-request-id{run.requestId}
x-rb-account{run.account}
x-rb-user-agentMozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0
x-rb-acceptapplication/json, text/plain, */*
x-rb-accept-languageen-US,en;q=0.5
x-rb-accept-encodinggzip, deflate, br, zstd
x-rb-refererhttps://shop.example.com/orders?page=2
x-rb-originhttps://shop.example.com
x-rb-sec-fetch-destempty
x-rb-sec-fetch-modecors
x-rb-sec-fetch-sitesame-origin
x-rb-priorityu=4
x-rb-pragmano-cache
x-rb-cache-controlno-cache
x-rb-tetrailers
x-rb-dnt1
x-rb-sec-gpc1
x-rb-forwarded-for203.0.113.195, 198.51.100.17
x-rb-forwarded-protohttps
x-rb-forwarded-hostshop.example.com
x-rb-forwarded-port443
x-rb-real-ip203.0.113.195
x-rb-via1.1 cdn-edge, 1.1 envoy
x-rb-traceparent00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
x-rb-tracestaterojo=00f067aa0ba902b7,congo=t61rcWkgMzE
x-rb-envoy-attempt-count1
x-rb-amzn-trace-idRoot=1-66e9b7c2-5759e988bd862e3fe1be46a9

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}]}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/headers/many.ts
tests/headers/many.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";
import { BROWSER_AND_PROXY } from "#models/fixture";

const path = "/headers";

export default performanceTest({
  id: { family: "headers", name: "many" },
  path,
  base: "headers.few",
  varies: "header_count",
  heft: 2,
  about:
    "Thirty request headers, still read by nothing. Read against headers.few, " +
    "the difference is the cost of materialising twenty-five more that nobody " +
    "asked for, which is about a kilobyte and close to what a real request " +
    "carries.",

  request: (c) => {
    let call = c
      .get(path)
      .header("x-rb-tenant", c.run.tenant)
      .header("x-rb-request-id", c.run.requestId)
      .header("x-rb-account", String(c.run.account));

    for (const [name, value] of BROWSER_AND_PROXY) call = call.header(name, value);

    return call.okWith(items.small);
  },
});