Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix replacement for cgi module #19

Closed
wants to merge 9 commits into from
3 changes: 2 additions & 1 deletion multiurl/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def parse_separated_header(value: str):

m = Message()
m["content-type"] = value
return dict(m.get_params())
e1, e2 = m.get_params()
return e1[0], dict([e2])


class HTTPDownloaderBase(DownloaderBase):
Expand Down
13 changes: 13 additions & 0 deletions tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pytest

from multiurl import Downloader, download
from multiurl.http import FullHTTPDownloader


def test_http():
Expand Down Expand Up @@ -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")
Expand Down
Loading