✨ Mimetype guessing for the webcam test

Related to #3207
This commit is contained in:
Gina Häußge committed 2019-07-01 17:17:34 +02:00
1 parent e27c216a05
commit 2c6568acd1
4 files changed
+20 -4

No files matched your search

+10
View File
@@ -464,7 +464,17 @@ def _test_url(data):
response_result = dict(headers=dict(response.headers),
content_type=content_type)
if not content_type and data.get("content_type_guess") in valid_boolean_trues:
content = response.content
content_type = util.guess_mime_type(bytearray(content))
if not content_type:
content_type = "application/octet-stream"
response_result = dict(assumed_content_type=content_type)
parsed_content_type = util.parse_mime_type(content_type)
in_whitelist = content_type_whitelist is None or any(
map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_whitelist))
in_blacklist = content_type_blacklist is not None and any(