v157 · privacy · gpc

The origin's side of the handshake

Users signal with Sec-GPC; origins answer at /.well-known/gpc.json — the GPC support resource. The spec is strict about its shape: a gpc member that must be a boolean, an optional lastUpdate that must be an RFC3339 full-date or date-time, and anything else means the origin's support is unknown, never assumed. This page fetches five really-served variants and runs that validation for each.

The variants below are served by this demo's own Deno route so every branch is real HTTP, not hardcoded text. On a production origin the resource must live at the origin root: https://example.org/.well-known/gpc.json — a path-relative copy like this one is for exercising the validator, and the verdict column tells you exactly why each body parses the way it does.

Fetch and validate the served variants

Served body → spec verdict
variantHTTPbody as servedsupport verdictlastUpdate
Nothing fetched yet — pick a variant.

code path

const res = await fetch(new URL("/.well-known/gpc.json", origin));
if (!res.ok) return "unknown";              // absent resource: support unknown
const data = await res.json();
const support =
  data.gpc === true  ? "supports" :
  data.gpc === false ? "refuses"  :
  "unknown";                                 // any other value: unknown
// lastUpdate must be RFC3339 full-date or date-time, else "unknown time"
const RFC3339 = /^\d{4}-\d{2}-\d{2}([Tt ]\d{2}:\d{2}:\d{2}(\.\d+)?([Zz]|[+-]\d{2}:\d{2}))?$/;
const lastUpdate = RFC3339.test(String(data.lastUpdate ?? "")) ? data.lastUpdate : null;

see also