Skip to content
BENIBIX Learn

HTTP Header

Infrastructure🌐 NetworkingRequests and Responses

Also known as Header, Request Header, Response Header, HTTP Headers

A label on a web request or reply. Each has a name and a value.

Think of it like

Think of it like the notes on the outside of a parcel. Fragile, this way up, from Emma.

Example

Emma's app sends Authorization: Bearer with her token in a header. The server reads it and knows who she is.

Why it matters

Your login, the file type and how long to keep a copy all ride in headers. Many bugs hide there.

Definition

An HTTP header is a name and a value sent with a request or a response. One example is Content-Type: application/json. Headers carry details about the message, not the message itself. They say what kind of data is inside, who is asking, what language is wanted and how long to keep a copy. A request or response can carry dozens of them. Each one sits on its own line, before the body.

Example code

http
Content-Type: application/json
Accept-Language: en
Cache-Control: max-age=3600
Three headers: the data type, the language wanted and how long to cache.

Common mistake

Forgetting Content-Type on a request with a JSON body. The server may not read the body at all.

Key takeaways

  1. 1
    Name and value. One per line.
  2. 2
    About the message. Not the message itself.
  3. 3
    Both ways. Requests and responses.

Learn it properly