client: cleanup

This commit is contained in:
2021-03-21 13:10:57 +01:00
parent d8a5765fd8
commit 638576f471
5 changed files with 77 additions and 128 deletions

View File

@@ -1,16 +1,17 @@
import logging
from abc import ABC, abstractmethod
from typing import Dict
from client.httpclient import HTTPClient, BUFSIZE, IncompleteResponse, InvalidResponse, UnsupportedEncoding
class Retriever:
class Retriever(ABC):
client: HTTPClient
headers: Dict[str, str]
def __init__(self, client: HTTPClient):
self.client = client
@abstractmethod
def retrieve(self):
pass
@@ -95,7 +96,7 @@ class ChunkedRetriever(Retriever):
def retrieve(self):
while True:
chunk_size = self._get_chunk_size()
chunk_size = self.__get_chunk_size()
logging.debug("chunk-size: %s", chunk_size)
if chunk_size == 0:
self.client.reset_request()
@@ -108,7 +109,7 @@ class ChunkedRetriever(Retriever):
self.client.read_line() # remove CRLF
return b""
def _get_chunk_size(self):
def __get_chunk_size(self):
line = self.client.read_line()
sep_pos = line.find(";")
if sep_pos >= 0: