'Encode and write a Record to a socket.'

def write(self, sock):

    self.paddingLength = ((- self.contentLength) & 7)
    if __debug__:
        _debug(9, ('write:    fd    =    %d,    type    =    %d,    requestId    =    %d,    contentLength    =    %d' % (sock.fileno(), self.type, self.requestId, self.contentLength)))
    header = struct.pack(FCGI_Header, self.version, self.type, self.requestId, self.contentLength, self.paddingLength)
    self._sendall(sock, header)
    if self.contentLength:
        self._sendall(sock, self.contentData)
    if self.paddingLength:
        self._sendall(sock, ('\x00' * self.paddingLength))
