'Prepare the sequence of name, value tuples into a form suitable for
transmitting on the wire for HTTP.'

def encode_header_items(cls, header_items):

    for (k, v) in header_items:
        if isinstance(k, unicodestr):
            k = cls.encode(k)
        if (not isinstance(v, basestring)):
            v = str(v)
        if isinstance(v, unicodestr):
            v = cls.encode(v)
        k = k.translate(header_translate_table, header_translate_deletechars)
        v = v.translate(header_translate_table, header_translate_deletechars)
        (yield (k, v))
