What is an HTTP header?
Short answer
An HTTP header is a name/value line that carries metadata alongside a request or response, such as the content type, caching rules, or authentication. Headers describe the message; the body carries the actual data.
Metadata for the message
Every HTTP request and response can include headers: simple Name: value lines sent before the body. They tell each side how to interpret the message, who is making it, and how it may be cached or secured.
Content-Type: application/json
Cache-Control: max-age=3600
Content-Length: 348Request vs response headers
- Request:
Authorization(credentials),Accept(formats wanted),User-Agent(the client) - Response:
Content-Type(the format returned),Set-Cookie,Cache-Control - Either:
Content-Length, customX-headers
Content-Type and content-type are the same header. Values, however, are usually case-sensitive.Some headers are specifically about safety. See What are HTTP security headers?.