def to_stream(self, stream, prepends_only=False):
        """
        Takes a stream and serializes headers in a mime format.
        """
        i = 0
        for h, v in self.iteritems(raw=True):
            if prepends_only and i == self.num_prepends:
                break
            i += 1
            try:
                h = h.encode('ascii')
            except __HOLE__:
                raise EncodingError("Non-ascii header name")
            stream.write("{0}: {1}\r\n".format(h, to_mime(h, v)))
dataset/ETHPy150Open mailgun/flanker/flanker/mime/message/headers/headers.py/MimeHeaders.to_stream