A request header is part of a client request which contains crucial metadata about the request and the client. It shares important preferences for response formats, authentication credentials, and caching instructions that determine how responses eventually reach their destinations. We typically attribute request headers to HTTP requests, and headers have a large impact on data transmission over the network.

How do request headers work?

First, each request header has a standardized structure that leaves room for the inclusion or omission of information, based on relevance. For example, while each request typically contains a User-Agent field, a Cache-Control directive isn't always present to determine browser caching behavior. Each request header's key-value pairs format helps the server (or an intermediary load balancer) parse the information effectively. 

There are many types of request headers: 

  • User-Agent – Describes the client's web browser, underlying browser framework, operating system, and CPU architecture

  • Content-Type – Specifies the type and format of data sent within the request body, like JSON or XML

  • Authorization – Provides authentication credentials such as tokens, usernames, or passwords 

  • Accept – Dictates accepted media types for responses sent to the client

  • Cache-Control – Determines caching behavior at the browser level, based on age, duration, and other factors like privacy level

It's also possible to create custom headers to define more parameters within HTTP's specification. Overall, request headers enable successful, two-way communication between devices while maximizing control over data that's sent and received.

How are request headers handled in HAProxy?

HAProxy lets you inspect and manipulate request headers in numerous ways. You can add, set, delete, or replace these headers according to needs or preferences. It's also possible to capture a request header. To better understand how HTTP headers are handled in HAProxy, check out our HTTP headers documentation.