'Internal: get a response plus following text from the server.
Raise various errors if the response indicates an error.'

def getlongresp(self, file=None):

    openedFile = None
    try:
        if isinstance(file, str):
            openedFile = file = open(file, 'w')
        resp = self.getresp()
        if (resp[:3] not in LONGRESP):
            raise NNTPReplyError(resp)
        list = []
        while 1:
            line = self.getline()
            if (line == '.'):
                break
            if (line[:2] == '..'):
                line = line[1:]
            if file:
                file.write((line + '\n'))
            else:
                list.append(line)
    finally:
        if openedFile:
            openedFile.close()
    return (resp, list)
