Routines to generate WSGI responses
This represents response headers. It handles the headers as a dictionary, with case-insensitive keys.
Also there is an .add(key, value) method, which sets the key, or adds the value to the current value (turning it into a list if necessary).
For passing to WSGI there is a .headeritems() method which is like .items() but unpacks value that are lists. It also handles encoding – all headers are encoded in ASCII (if they are unicode).
@@: Should that encoding be ISO-8859-1 or UTF-8? I’m not sure what the spec says.
Returns the header’s value, or None if no such header. If a header appears more than once, all the values of the headers are joined with ‘,’. Note that this is consistent /w RFC 2616 section 4.2 which states:
It MUST be possible to combine the multiple header fields into one “field-name: field-value” pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma.
However, note that the original netscape usage of ‘Set-Cookie’, especially in MSIE which contains an ‘expires’ date will is not compatible with this particular concatination method.