From be72c2f84754bb5d68f18a6a2d033e0a1d12f1c3 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 15 Feb 2021 18:09:09 +0100 Subject: [PATCH] Use head requests again for fetching the response headers Seems like github now returns the correct HTTP headers for heade requests as well. --- app/fetch.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/fetch.py b/app/fetch.py index 0101ae5..b771304 100644 --- a/app/fetch.py +++ b/app/fetch.py @@ -223,11 +223,10 @@ async def check_needs_update(_cache_key: List[str] = [""]) -> bool: if appconfig.CACHE_LOCAL: return True - # XXX: github doesn't support redirects with HEAD and returns bogus headers async def get_headers(client: httpx.AsyncClient, *args: Any, **kwargs: Any) -> httpx.Headers: - async with client.stream('GET', *args, **kwargs) as r: - r.raise_for_status() - return r.headers + r = await client.head(*args, **kwargs) + r.raise_for_status() + return r.headers combined = "" async with httpx.AsyncClient() as client: