~ihabunek/toot-discuss

tooi: load_image: follow redirects by default v1 PROPOSED

Lexi Winter: 1
 load_image: follow redirects by default

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~ihabunek/toot-discuss/patches/48537/mbox | git am -3
Learn more about email & git

[PATCH tooi] load_image: follow redirects by default Export this patch

Sometimes the Mastodon image URL is a redirect; let httpx follow
redirects so we can load these correctly.
---
 tooi/utils/images.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tooi/utils/images.py b/tooi/utils/images.py
index 8bb8911..0cf0cba 100644
--- a/tooi/utils/images.py
+++ b/tooi/utils/images.py
@@ -55,7 +55,7 @@ def load_image(url: str, width: int, height: int) -> Iterator[Image.Image]:
    # TODO: cache fetched images to disk in XDG_CACHE_DIR?
    # This would allow cache to persist between runs
    with tempfile.SpooledTemporaryFile(max_size=5 * 1024 * 1024) as tmp:
        with httpx.stream("GET", url) as response:
        with httpx.stream("GET", url, follow_redirects=True) as response:
            response.raise_for_status()
            for data in response.iter_bytes():
                tmp.write(data)
-- 
2.43.0