← Lessons

quiz vs the machine

Silver1090

Networking

Request and Response Headers

How metadata travels alongside the body in both directions.

4 min read · intro · beat Silver to climb

Metadata for Each Message

Headers carry metadata about a message: who sent it, what the body contains, and how it should be handled. Both requests and responses use the same name and value format, but the useful headers differ by direction.

Common Request Headers

  • Host names the target site so one server can serve many domains.
  • User Agent identifies the client software.
  • Accept lists media types the client can handle.
  • Authorization carries credentials.

Common Response Headers

  • Content Type declares the media type of the body.
  • Content Length gives the body size in bytes.
  • Server names the software answering.
  • Set Cookie asks the client to store state.

Representation vs Connection

Some headers describe the representation, such as Content Type, while others describe the connection or message, such as Connection or Transfer Encoding. Treating these groups separately keeps caching and proxying correct.

Key idea

Headers attach metadata to both requests and responses using a shared name and value form, with request headers describing intent and response headers describing the returned representation.

Check yourself

Answer to earn rating on the learn ladder.

1. Which header lets one server host many domains on one address?

2. Which header declares the media type of a response body?