An HTTP header is a key-value field included in an HTTP request or response to provide metadata about the message.
Headers can describe the client, server, content type, authentication method, caching policy, cookies, accepted formats, and many other details related to web communication.
HTTP headers are essential for browsers, APIs, proxies, web servers, and automated data systems.
Also known as: Request header, response header, HTTP metadata.
HTTP headers are transmitted alongside an HTTP request or response.
A typical request may include:
GET /products HTTP/1.1
Host: example.com
Accept: application/json
User-Agent: ExampleClient/1.0
The server may return:
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=3600
Each header communicates additional information about how the request or response should be handled.
Request headers are sent from the client to the server.
They may describe:
Common request headers include:
Host
User-Agent
Accept
Authorization
Cookie
Accept-Language
Accept-Encoding
Referer
Origin
Response headers are sent from the server to the client.
They may describe:
Common response headers include:
Content-Type
Content-Length
Cache-Control
Set-Cookie
Location
Server
ETag
Last-Modified
An HTTP header usually follows this format:
Header-Name: value
For example:
Content-Type: application/json
or:
Authorization: Bearer TOKEN
The header name identifies the type of metadata, while the value contains the corresponding information.
The Host header identifies the hostname of the server being requested.
For example:
Host: example.com
This is especially important when multiple websites share the same IP address.
The User-Agent header identifies information about the client making the request.
For example:
User-Agent: ExampleBrowser/1.0
Servers may use this information for compatibility, analytics, or traffic classification.
The Accept header tells the server which response formats the client can process.
For example:
Accept: application/json
The Authorization header carries authentication credentials or tokens.
For example:
Authorization: Bearer TOKEN
The Cookie header sends previously stored cookies back to the server.
For example:
Cookie: session_id=abc123
The Content-Type header tells the client what type of content is being returned.
Examples include:
text/html
application/json
image/png
text/css
For example:
Content-Type: application/json
The Content-Length header indicates the size of the response body in bytes.
The Set-Cookie header instructs the client to store a cookie.
For example:
Set-Cookie: session_id=abc123
The Location header often specifies the destination of a redirect.
For example:
Location: /new-page
The Cache-Control header defines caching behavior.
For example:
Cache-Control: max-age=3600
This tells compatible caches that the response may be reused for a limited period.
Headers provide metadata about the message.
The body contains the actual content being transferred.
For example:
Content-Type: application/json
is a header, while:
{
"product": "Wireless Mouse",
"price": 29.99
}
is the response body.
In simple terms:
Query parameters are included in the requested path.
For example:
/products?category=electronics
Headers are separate metadata fields sent with the request.
In simple terms:
Both can influence server behavior.
HTTP headers allow clients and servers to negotiate formats.
For example, a client may send:
Accept: application/json
to request JSON.
Another client may request:
Accept: text/html
The server can return different formats depending on what it supports.
Many APIs use headers for authentication.
A common pattern is:
Authorization: Bearer TOKEN
The server validates the supplied credential before allowing access to protected resources.
Authentication headers should be transmitted over encrypted HTTPS connections.
Caching behavior is often controlled through headers.
Examples include:
Cache-Control
ETag
Last-Modified
Expires
These headers help browsers, proxies, and content delivery systems determine whether they can reuse a previously downloaded response.
Cookies are exchanged through HTTP headers.
The server may create a cookie with:
Set-Cookie: session_id=abc123
The client can later return it with:
Cookie: session_id=abc123
This allows websites to maintain session state across multiple HTTP requests.
Proxies receive and forward HTTP requests, so they may also process headers.
Depending on configuration, a proxy may:
Common proxy-related headers may include fields used to describe forwarded requests or intermediary infrastructure.
The exact headers depend on the proxy and server configuration.
HTTP headers are important in API clients and web data workflows because servers can use them to determine how to process a request.
A data collection client may need to send headers such as:
Accept
Authorization
Content-Type
Cookie
User-Agent
For example, an API request may require:
Accept: application/json
Authorization: Bearer TOKEN
Without the expected headers, the server may return a different response or reject the request.
HTTP headers can contain sensitive or security-related information.
Examples include:
Applications should avoid exposing secrets in logs and should use HTTPS when transmitting sensitive header values.
Servers should also validate incoming headers rather than assuming all client-supplied values are trustworthy.
Suppose an application requests product data from an API.
The request may look like:
GET /products/1001 HTTP/1.1
Host: example.com
Accept: application/json
Authorization: Bearer TOKEN
The server may respond:
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-cache
with a body such as:
{
"id": 1001,
"name": "Wireless Mouse",
"price": 29.99
}
In this exchange, the headers describe how the request is authenticated, what format the client expects, and how the returned content should be handled.
An HTTP header is a metadata field included with an HTTP request or response.
Request headers tell servers about the client and how the request should be processed, while response headers describe the returned content and server behavior. Headers play an important role in authentication, caching, cookies, proxies, APIs, content negotiation, and web data workflows.