4Suite API Documentation

Module Ft.Server.Server.Http.HeaderDict

MIME message header storage for HTTP

Copyright 2005 Fourthought, Inc. (USA).
Detailed license and copyright information: http://4suite.org/COPYRIGHT
Project home, documentation, distributions: http://4suite.org/
Classes:
Fields:

Classes

class HeaderDict(__builtin__.dict)
A dictionary-like object for storing MIME-like message headers. Headers are stored in the object via regular dictionary interfaces. They are retrieved via str(), repr() or self.terse(), which returns a standard dict with duplicate headers merged into a comma-separated list of values (even when it is not OK to do so).

The reason this class is needed is because the dictionary interface of
the Message class of the rfc822 and mimetools modules allows each new
header to overwrite a previously-stored header with the same key. Our
HeaderDict class stores its header values as lists, so no data is lost.
Its keys are accessed case-insensitively and are always written out
in a normalized format where usually only the first letter of each
hyphen-separated word is capitalized. (Content-MD5, ETag, TE, and
WWW-Authenticate are exceptions to this rule). The str(obj)
representation prints the headers in a convenient format suitable for
printing in a MIME-like message.

Methods

__contains__(self, key)
# case-insensitive 'key in dict' lookup
__delitem__(self, key)
# case-insensitive deletion: removes entire list
__getitem__(self, key)
# case-insensitive lookup
__init__(self, obj=None)
__iter__(self)
# case-insensitive 'for key in dict' iteration
__repr__(self)
# string representations
__setitem__(self, key, value)
# case-insensitive storage; appends to a list
__str__(self)
get(self, key, default=None)
# retrieve a value or default if no such key
has_key(self, key)
# case-insensitive key lookup
iteritems(self)
# case-insensitive 'for key in dict' iteration
keys(self)
# normalize key names
terse(self)
# return a terse dictionary (duplicate headers in one comma-separated string) # this is for compatibility with functions want to read the header values as # a single string rather than as a python list of strings
update(self, dict_)
# append another dict or HeaderDict

Methods inherited from class __builtin__.dict

__cmp__, __eq__, __ge__, __getattribute__, __gt__, __hash__, __le__, __len__, __lt__, __ne__, __new__, clear, copy, items, itervalues, pop, popitem, setdefault, values

Methods inherited from class __builtin__.object

__delattr__, __reduce__, __reduce_ex__, __setattr__

Fields

__dict__ = <attribute '__dict__' of 'HeaderDict' objects>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'HeaderDict' objects>
list of weak references to the object (if defined)
forceCaps = {'content-md5': 'Content-MD5', 'etag': 'ETag', 'te': 'TE', 'www-authenticate': 'WWW-Authenticate'}

Fields

Fields

Fields

generators = _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 4096)