Implement Client.each_response_line()
This commit is contained in:
parent
3067b812d5
commit
a145b34726
1 changed files with 18 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue