chickadee » intarweb » headers

headers ALIST #!optional HEADERSprocedure

This creates a header object based on an input list.

Requests and responses contain HTTP headers wrapped in a special header-object to ensure they are properly normalized.

The input list has header names (symbols) as keys, and lists of values as values:

(headers `((host ("example.com" . 8080))
           (accept #(text/html ((q . 0.5)))
                   #(text/xml ((q . 0.1))))
           (authorization #("Bearer: token" raw)))
          old-headers)

This adds the named headers to the existing headers in old-headers. The host header is a pair of hostname/port. The accept header is a list of allowed mime-type symbols. The authorization header is a list with a raw value.

As can be seen here, optional parameters or "attributes" can be added to a header value by wrapping the value in a vector of length 2. The first entry in the vector is the header value, the second is an alist of attribute name/value pairs, or the symbol raw, in which case the header value will be kept as-is when writing the response.