From 0b75814ca2335a848f9b0288b446b689d5d04a55 Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Mon, 11 Nov 2024 17:36:47 +0000 Subject: [PATCH] Fix content-disposition handling - add test --- tests/test_downloader.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_downloader.py b/tests/test_downloader.py index 6e7a4c3..1d12f70 100644 --- a/tests/test_downloader.py +++ b/tests/test_downloader.py @@ -13,6 +13,7 @@ import pytest from multiurl import Downloader, download +from multiurl.http import FullHTTPDownloader def test_http(): @@ -77,6 +78,18 @@ def test_order(): assert f.read()[:4] == b"BUFR" +def test_content_disposition_handling(): + class TestDownloader(FullHTTPDownloader): + def headers(self): + headers = super().headers() + headers["content-disposition"] = 'attachment; filename="temp.bufr"' + return headers + + TestDownloader( + url="http://get.ecmwf.int/test-data/metview/gallery/temp.bufr", + ).download(target="out") + + @pytest.mark.skip(reason="ftpserver not defined") def test_ftp_download(tmp_path, ftpserver): local_test_file = os.path.join(tmp_path, "testfile.txt")