class documentation

class HTTPHeaderDict(MutableMapping): (source)

View In Hierarchy

: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_httplib 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_from Undocumented
Class Variable __marker Undocumented
Instance Variable _container Undocumented
@classmethod
def from_httplib(cls, message): (source)

Read headers from a Python 2 httplib message object.

def __contains__(self, key): (source)

Undocumented

def __delitem__(self, key): (source)

Undocumented

def __eq__(self, other): (source)

Undocumented

def __getitem__(self, key): (source)

Undocumented

def __init__(self, headers=None, **kwargs): (source)

Undocumented

def __iter__(self): (source)

Undocumented

def __len__(self): (source)

Undocumented

def __ne__(self, other): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def __setitem__(self, key, val): (source)

Undocumented

def add(self, key, val): (source)

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'

def copy(self): (source)

Undocumented

def discard(self, key): (source)

Undocumented

def extend(self, *args, **kwargs): (source)

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__

def getlist(self, key, default=__marker): (source)

Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.

def items(self): (source)

Undocumented

def iteritems(self): (source)

Iterate over all header lines, including duplicate ones.

def itermerged(self): (source)

Iterate over all headers, merging duplicate ones together.

def pop(self, key, default=__marker): (source)

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.

def _copy_from(self, other): (source)

Undocumented

__marker = (source)

Undocumented

_container = (source)

Undocumented