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.
This commit is contained in:
I-Al-Istannen 2020-07-15 15:10:31 +02:00
parent 2aed4f6d1f
commit 5c4c785e60

View File

@ -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")