From d428858f1ed43e36f3190ff9324b9b8cda07bbd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 21 Oct 2020 15:16:15 +0200 Subject: [PATCH] fix: Do now fail on requests returning plain text Fix #639 --- pymisp/api.py | 2 +- tests/testlive_comprehensive.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index c64b8e4..05c3b25 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -2973,7 +2973,7 @@ class PyMISP: logger.debug(response.text) if expect_json: raise PyMISPUnexpectedResponse(f'Unexpected response from server: {response.text}') - if lenient_response_type and not response.headers['Accept'].startswith('application/json'): + if lenient_response_type and not response.headers['Content-Type'].startswith('application/json'): return response.text if not response.content: # Empty response diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 0fd76da..40f18b8 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -1818,6 +1818,11 @@ class TestComprehensive(unittest.TestCase): event_get = MISPEvent() event_get.from_dict(**r) self.assertDictEqual(event.to_dict(), event_get.to_dict()) + r = self.user_misp_connector.direct_call('events/restSearch', data={"returnFormat": "csv", + "type": {"AND": ["campaign-name", "threat-actor"]}, + "category": "Attribution", "includeEventUuid": 1}) + self.assertTrue(r.startswith('uuid,event_id,category,type,value')) + finally: self.admin_misp_connector.delete_event(event)