CodePark/ questions / How a request travels
START PRACTICINGPRACTICE
Backend question · HTTP & API design › How a request travels

In HTTP/1.1, which request header must every request carry, so that the server answers 400 if it is missing?

Host

HTTP/1.1 requires a Host header on every request. The reason is virtual hosting: one IP address can serve many sites, so the server needs Host to know which site you want. A server must reject a request without Host with status 400.

The other options are not required:

• "
Content-Type" only describes a body, so it matters only when the request has a body.
• "
User-Agent" is optional.
• "
Accept" is optional.