diff --git a/lib/nntp/tiny/client.py b/lib/nntp/tiny/client.py index 76e2d0e..3ef53e8 100644 --- a/lib/nntp/tiny/client.py +++ b/lib/nntp/tiny/client.py @@ -9,6 +9,10 @@ from nntp.tiny.response import Response, ResponseCode class ClientException(Exception): pass +class ClientEOFException(ClientException): + def __str__(self): + return 'Unexpected client EOF' + class Client(Connection): RE_SPLIT = re.compile(r'\s+') @@ -42,7 +46,6 @@ class Client(Connection): self.host = host self.port = port - self.tls = tls super().__init__(sock) @@ -55,3 +58,17 @@ class Client(Connection): self.print(' '.join(args)) return self._read_response() + + def each_response_line(self): + while True: + line = self.readline() + + if line == '': + raise ClientEOFException() + + line = line.rstrip() + + if line == '.': + break + + yield line