diff options
author | Maxim Devaev <[email protected]> | 2021-07-28 15:10:07 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2021-07-28 15:10:07 +0300 |
commit | da2e86ae72d0cb91e5678932278a4b6631c7e2cb (patch) | |
tree | 34c123b518e00cf2a2c00fe96df3cc4910583cdc /kvmd | |
parent | 9aa3998924bc484476b620ce4957add2b7ee60f5 (diff) |
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/kvmd/api/msd.py | 2 | ||||
-rw-r--r-- | kvmd/htclient.py | 10 |
2 files changed, 1 insertions, 11 deletions
diff --git a/kvmd/apps/kvmd/api/msd.py b/kvmd/apps/kvmd/api/msd.py index 1f1afd1e..a8d44e5e 100644 --- a/kvmd/apps/kvmd/api/msd.py +++ b/kvmd/apps/kvmd/api/msd.py @@ -123,7 +123,7 @@ class MsdApi: name = htclient.get_filename(remote) name = valid_msd_image_name(name) - size = htclient.get_content_length(remote) + size = valid_int_f0(remote.content_length) get_logger(0).info("Downloading image %r as %r to MSD ...", url, name) async with self.__msd.write_image(name, size) as chunk_size: diff --git a/kvmd/htclient.py b/kvmd/htclient.py index 1927ede2..208f94b5 100644 --- a/kvmd/htclient.py +++ b/kvmd/htclient.py @@ -51,16 +51,6 @@ def raise_not_200(response: aiohttp.ClientResponse) -> None: ) -def get_content_length(response: aiohttp.ClientResponse) -> int: - try: - value = int(response.headers["Content-Length"]) - except Exception: - raise aiohttp.ClientError("Empty or invalid Content-Length") - if value < 0: - raise aiohttp.ClientError("Negative Content-Length") - return value - - def get_filename(response: aiohttp.ClientResponse) -> str: try: disp = response.headers["Content-Disposition"] |