HTTP header

A named line of metadata in an HTTP message, such as Content-Type: application/json, that describes the body, the caller or how to handle the exchange.

In more detail

Header names are case-insensitive and many values are comma-separated lists. Request headers describe the caller and what it accepts; response headers describe the body, caching rules and related links. Look for a standard header before inventing your own, because caches, proxies, browsers and client libraries already understand the standard ones.

Examples

In the browser: Headers control caching, cookies, content types, security policies and CORS.
Content-Type, Set-Cookie, traceparent, x-correlation-id, Last-Event-ID, Retry-After
w.Header().Set("Content-Type", "text/plain")
Go: w.Header().Set("Content-Type", "text/plain") before writing the body
Headers describe the body's format, caching rules, the target host, authentication and identifiers for tracing a request. Reverse proxies often add headers such as X-Forwarded-For to pass on the original client address. Inspect them alongside the body when diagnosing.
Headers carry the caller identity in the course's HTTP labs and switch on browser protections in responses.
In this course: Contracts should avoid pinning incidental headers the consumer does not rely on, or they break for no useful reason. Headers are case-insensitive names followed by a value, one per line.

Related terms

Taught in

References