1. HTTP (Hypertext Transfer Protocol)

  1. HTTP Headers

  1. Max-Forwards
    1. Writing requests (user agent clients)
    2. Intermediaries
    3. Reading requests (origin server)
    4. Overview table
    5. Syntax
      1. Example

Max-Forwards

The Max-Forwards header limits the number of intermediate nodes an HTTP message may pass through. It is used primarially with the TRACE method to debug HTTP routing through caches and proxies.

When a node receives a message with the Max-Forwards header, it must forward the header with the value deincremented by one. If the received value is zero (and so cannot be deincremented further), the node becomes authortative for the given request, instead of the origin server.

Writing requests (user agent clients)

User agents do not typically use the Max-Forwards header, except by developers when debugging routing configurations. An algorithm similar to traceroute may be used to debug configurations: Try a TRACE request with Max-Forwards: 0, and note the response, which will be from the node being connected to. The headers that were sent will probably match those in the response message. Retry the request, incrementing the value each try.

This header is only guarenteed to work when used with the TRACE and OPTIONS methods, as servers do not have to implement it for other methods.

Intermediaries

Intermediate nodes MUST look for the presence of the Max-Forwards header. If it exists and the value is 0, then respond as if the final recipient. Otherwise, the outgoing request message must include this header with the value deincremented by one.

Intermediate nodes MUST NOT add the header if they did not receive it.

Nodes may ignore the header for methods besides TRACE and OPTIONS.

Reading requests (origin server)

The origin server ignores the Max-Forwards header, since the server is authortative for the message and is going to respond to the message regardless of the Max-Forwards value.

Overview table

Name
Max-Forwards
Description
Limits how many intermediate nodes a message can pass through.
Direction
Request
Specification
RFC 7231: HTTP/1.1 Semantics and Content ยง5.1.2. Max-Forwards

Syntax

Max-Forwards = 1*DIGIT

Example

TRACE / HTTP/1.1
Host: example.com
Max-Forwards: 0

An intermediate node receiving this message must always respond, in this case, the TRACE method specifies reflecting back the received HTTP headers in the response body.