'Returns the named header; an error if there is not exactly one
matching header (unless you give a default -- always an error
if there is more than one header)'

def header(self, name, default=NoDefault):

    found = None
    for (cur_name, value) in self.headers:
        if (cur_name.lower() == name.lower()):
            assert (not found), ('Ambiguous    header:    %s    matches    %r    and    %r' % (name, found, value))
            found = value
    if (found is None):
        if (default is NoDefault):
            raise KeyError(('No    header    found:    %r    (from    %s)' % (name, ',    '.join([n for (n, v) in self.headers]))))
        else:
            return default
    return found
