def pack(self):
        """
        Create a string representation from object state.

        @return: The string (bytes) for this stomp frame.
        @rtype: C{str}
        """

        self.headers.setdefault('content-length', len(self.body))

        # Convert and append any existing headers to a string as the
        # protocol describes.
        headerparts = ("{0}:{1}\n".format(key, value)
                       for key, value in self.headers.items())

        # Frame is Command + Header + EOF marker.
        return six.b("{0}\n{1}\n".format(self.cmd, "".join(headerparts))) + (self.body if isinstance(self.body, six.binary_type) else six.b(self.body)) + six.b('\x00')