[Web-SIG] Why is response_headers a list instead of a dict?
Clark C. Evans
cce at clarkevans.com
Sun Dec 25 04:45:34 CET 2005
Why is response_headers a list instead of a dict?
>From RFC 2616 Section 4.2:
The order in which header fields with differing field names are
received is not significant. However, it is "good practice" to send
general-header fields first, followed by request-header or response-
header fields, and ending with the entity-header fields.
Multiple message-header fields with the same field-name MAY be
present in a message if and only if the entire field-value for that
header field is defined as a comma-separated list [i.e., #(values)].
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.
In other words: (a) order does not matter, (b) it is reasonable to
restrict a header field to a single (header_name, header_value) pair.
Indeed, according to the specification, a HTTP Proxy could re-arrange
headers and condense N headers of the same type by simply concatenating
their values with a comma.
I'm asking this because it is quite painful (and very much an unnecessary
pain) to work with headers in complex WSGI-based middleware applications.
Kind Regards,
Clark
More information about the Web-SIG
mailing list