def to_bytes(self, max_fragment_size = 2 ** 12):
        bytes = "".join([message.to_bytes() for message in self.messages])
        # Fragment the record as needed
        num_fragments = len(bytes)/max_fragment_size
        fragments = [bytes[i: i + max_fragment_size] for i in range (0, len(bytes), max_fragment_size)]
        return "".join([(struct.pack("B", self.content_type)
                    + self.version.to_bytes()
                    + struct.pack("!H", len(fragment))
                    + fragment) for fragment in fragments])
dataset/ETHPy150Open google/nogotofail/nogotofail/mitm/util/tls/types/record.py/TlsRecord.to_bytes/original