mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
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:
parent
2aed4f6d1f
commit
5c4c785e60
@ -139,8 +139,9 @@ class IliasDownloader:
|
|||||||
|
|
||||||
with self._session.get(url, stream=True) as response:
|
with self._session.get(url, stream=True) as response:
|
||||||
content_type = response.headers["content-type"]
|
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)):
|
if self._is_logged_in(soupify(response)):
|
||||||
raise ContentTypeException("Attempting to download a web page, not a file")
|
raise ContentTypeException("Attempting to download a web page, not a file")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user