HTTP Headers and representation metadata
Quick answer
Headers represents normalized HTTP header names and their values. Use it to inspect content metadata and build permitted request headers.
How it works
get(name) reads a header or returns null. set replaces the named value; append adds a value. Header names are case-insensitive. Browser-generated requests restrict some names and network response headers may be filtered or immutable. A constructed Headers object does not prove that a browser will transmit every supplied field.
Local examples
Run in a fresh browser document; no external network is needed. The actual ByteMind editor is unverified.
(async () => {const h=new Headers({"X-Mode":"draft"});h.set("x-mode","ready");console.log(h.get("X-MODE"),h.has("x-other"));})()Expected console output:
ready falseNames are case-insensitive; set replaces.
Run in a fresh browser document; no external network is needed. The actual ByteMind editor is unverified.
(async () => {const h=new Headers();h.append("X-Tag","a");h.append("X-Tag","b");console.log(h.get("x-tag"));})()Expected console output:
a, bFor this ordinary custom header, appended values are combined.
Common mistakes
Do not assume Content-Type is trustworthy schema validation. Missing headers return null, not an empty string.
Guided practice
Set and replace a custom test header and inspect its value using a different letter case.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTTP Headers and representation metadata — Knowledge Check
Apply the concept and reason about the example output.
What does Headers.get return for a missing name?
Which method replaces an existing header value?
Can a constructed header list guarantee actual browser transmission?
What is the expected console output of HTTP Headers and representation metadata example 1?
(async () => {const h=new Headers({"X-Mode":"draft"});h.set("x-mode","ready");console.log(h.get("X-MODE"),h.has("x-other"));})()What is the expected console output of HTTP Headers and representation metadata example 2?
(async () => {const h=new Headers();h.append("X-Tag","a");h.append("X-Tag","b");console.log(h.get("x-tag"));})()