'Read and decode a Record from a socket.'

def read(self, sock):

    try:
        (header, length) = self._recvall(sock, FCGI_HEADER_LEN)
    except:
        raise EOFError
    if (length < FCGI_HEADER_LEN):
        raise EOFError
    (self.version, self.type, self.requestId, self.contentLength, self.paddingLength) = struct.unpack(FCGI_Header, header)
    if __debug__:
        _debug(9, ('read:    fd    =    %d,    type    =    %d,    requestId    =    %d,    contentLength    =    %d' % (sock.fileno(), self.type, self.requestId, self.contentLength)))
    if self.contentLength:
        try:
            (self.contentData, length) = self._recvall(sock, self.contentLength)
        except:
            raise EOFError
        if (length < self.contentLength):
            raise EOFError
    if self.paddingLength:
        try:
            self._recvall(sock, self.paddingLength)
        except:
            raise EOFError
