'Encode a generic GNTP Message
:return string: GNTP Message ready to be sent. Returned as a byte string'

def encode(self):

    buff = _GNTPBuffer()
    buff.writeln(self._format_info())
    for (k, v) in self.headers.items():
        buff.writeheader(k, v)
    buff.writeln()
    for (resource, data) in self.resources.items():
        buff.writeheader('Identifier', resource)
        buff.writeheader('Length', len(data))
        buff.writeln()
        buff.write(data)
        buff.writeln()
        buff.writeln()
    return buff.getvalue()
