httphttp-headerschunked-encodingrfc2616

HTTP - Multiple Trailer Headers


I am trying to implement HTTP in my server, and am unable to find ANY information about how to handle multiple trailer header fields (with chunked encoding).

The standard (https://www.rfc-editor.org/rfc/rfc2616#section-14.40) states: "The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer-coding."

But gives no indication whatsoever of how to specify multiple headers in this the Trailer header.

For example, if a request or response had two trailer headers, Example1 and Example2, how would you structure the Trailer header?

Like this: Trailer: Example1 Example2 or Trailer: Example1,Example2 or what?


Solution

  • From RFC 2616:

    14.40 Trailer
    
           Trailer  = "Trailer" ":" 1#field-name
    
    
    2.1 Augmented BNF
    
    #rule
       A construct "#" is defined, similar to "*", for defining lists of
       elements. The full form is "<n>#<m>element" indicating at least
       <n> and at most <m> elements, each separated by one or more commas
       (",") and OPTIONAL linear white space (LWS).
    
    

    In other words, you should write:

    Trailer: Example1, Example2

    Note that RFC 2616 has been obsoleted by: