class HTTPHeaderDict(MutableMapping): (source)
:param headers: An iterable of field-value pairs. Must not contain multiple field names when compared case-insensitively. :param kwargs: Additional field-value pairs to pass in to ``dict.update``. A ``dict`` like container for storing HTTP Headers. Field names are stored and compared case-insensitively in compliance with RFC 7230. Iteration provides the first case-sensitive key seen for each case-insensitive pair. Using ``__setitem__`` syntax overwrites fields that compare equal case-insensitively in order to maintain ``dict``'s api. For fields that compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add`` in a loop. If multiple fields that are equal case-insensitively are passed to the constructor or ``.update``, the behavior is undefined and some will be lost. >>> headers = HTTPHeaderDict() >>> headers.add('Set-Cookie', 'foo=bar') >>> headers.add('set-cookie', 'baz=quxx') >>> headers['content-length'] = '7' >>> headers['SET-cookie'] 'foo=bar, baz=quxx' >>> headers['Content-Length'] '7'
Class Method | from |
Read headers from a Python 2 httplib message object. |
Method | __contains__ |
Undocumented |
Method | __delitem__ |
Undocumented |
Method | __eq__ |
Undocumented |
Method | __getitem__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __len__ |
Undocumented |
Method | __ne__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __setitem__ |
Undocumented |
Method | add |
Adds a (name, value) pair, doesn't overwrite the value if it already exists. |
Method | copy |
Undocumented |
Method | discard |
Undocumented |
Method | extend |
Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ |
Method | getlist |
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist. |
Method | items |
Undocumented |
Method | iteritems |
Iterate over all header lines, including duplicate ones. |
Method | itermerged |
Iterate over all headers, merging duplicate ones together. |
Method | pop |
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. |
Method | _copy |
Undocumented |
Class Variable | __marker |
Undocumented |
Instance Variable | _container |
Undocumented |
Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz'
Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.