| |
Methods defined here:
- __contains__ = has_key(self, name)
- __delitem__(self, name)
- Delete all occurrences of a header, if present.
Does *not* raise an exception if the header is missing.
- __getitem__(self, name)
- Get the first header value for 'name'
Return None if the header is missing instead of raising an exception.
Note that if the header appeared multiple times, the first exactly which
occurrance gets returned is undefined. Use getall() to get all
the values matching a header field name.
- __init__(self, headers)
- __len__(self)
- Return the total number of headers, including duplicates.
- __repr__(self)
- __setitem__(self, name, val)
- Set the value of a header.
- __str__(self)
- str() returns the formatted headers, complete with end line,
suitable for direct HTTP transmission.
- add_header(self, _name, _value, **_params)
- Extended header setting.
_name is the header field to add. keyword arguments can be used to set
additional parameters for the header field, with underscores converted
to dashes. Normally the parameter will be added as key="value" unless
value is None, in which case only the key will be added.
Example:
h.add_header('content-disposition', 'attachment', filename='bud.gif')
Note that unlike the corresponding 'email.Message' method, this does
*not* handle '(charset, language, value)' tuples: all values must be
strings or None.
- get(self, name, default=None)
- Get the first header value for 'name', or return 'default'
- get_all(self, name)
- Return a list of all the values for the named field.
These will be sorted in the order they appeared in the original header
list or were added to this instance, and may contain duplicates. Any
fields deleted and re-inserted are always appended to the header list.
If no fields exist with the given name, returns an empty list.
- has_key(self, name)
- Return true if the message contains the header.
- items(self)
- Get all the header fields and values.
These will be sorted in the order they were in the original header
list, or were added to this instance, and may contain duplicates.
Any fields deleted and re-inserted are always appended to the header
list.
- keys(self)
- Return a list of all the header field names.
These will be sorted in the order they appeared in the original header
list, or were added to this instance, and may contain duplicates.
Any fields deleted and re-inserted are always appended to the header
list.
- setdefault(self, name, value)
- Return first matching header value for 'name', or 'value'
If there is no header named 'name', add a new header with name 'name'
and value 'value'.
- values(self)
- Return a list of all header values.
These will be sorted in the order they appeared in the original header
list, or were added to this instance, and may contain duplicates.
Any fields deleted and re-inserted are always appended to the header
list.
|