From 5c4c785e60376f10e786e0c7d265669371452e70 Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Wed, 15 Jul 2020 15:10:31 +0200 Subject: [PATCH] Fix HTML file downloading Previously PFERD thought any HTML file was a "Error, no access" page when downloading. Now it checks whether ILIAS sends a content-disposition header, telling the browser to download the file. If that is the case, it was just a HTML file uploaded to ILIAS. If it has no header, it is probably an error message. --- PFERD/ilias/downloader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PFERD/ilias/downloader.py b/PFERD/ilias/downloader.py index f685f7a..f26c43c 100644 --- a/PFERD/ilias/downloader.py +++ b/PFERD/ilias/downloader.py @@ -139,8 +139,9 @@ class IliasDownloader: with self._session.get(url, stream=True) as response: content_type = response.headers["content-type"] + has_content_disposition = "content-disposition" in response.headers - if content_type.startswith("text/html"): + if content_type.startswith("text/html") and not has_content_disposition: if self._is_logged_in(soupify(response)): raise ContentTypeException("Attempting to download a web page, not a file")