Skip to content

Commit 926065a

Browse files
committed
Simplify filetype inference.
1 parent f9fc0e5 commit 926065a

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

asyncio_tutorial/fetcher.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ async def fetch_and_save_url(
2121
try:
2222
async with session.get(url) as resp:
2323
body = await resp.read()
24-
filetype = (
25-
resp.headers.get("Content-Type")
26-
.replace("; charset=UTF-8", "")
27-
.replace("text/", "")
28-
)
24+
filetype = resp.content_type.replace("text/", "")
2925
await write_file(url, body, filetype, directory)
3026
LOGGER.info(f"Fetched URL {i + 1} of {total_count}: {url}")
3127
except InvalidURL as e:

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)