Skip to content

Commit 439c398

Browse files
committed
Fix KeyError when getting the Content-Type
Unfortunately, there isn't a good way to add a test for this as mocket always adds the Content-Type header.
1 parent 92629ce commit 439c398

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
History
44
-------
55

6+
2.7.1 (2022-03-29)
7+
++++++++++++++++++
8+
9+
* Fixed ``KeyError`` when using the ``report()`` method. Reported by siang.
10+
GitHub #99.
11+
612
2.7.0 (2022-03-28)
713
++++++++++++++++++
814

minfraud/webservice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def report(self, report: Dict[str, Optional[str]], validate: bool = True) -> Non
618618

619619
response = self._do_request(uri, prepared_request)
620620
status = response.status_code
621-
content_type = response.headers["Content-Type"]
621+
content_type = response.headers.get("Content-Type")
622622
raw_body = response.text
623623
if status != 204:
624624
raise self._exception_for_error(status, content_type, raw_body, uri)
@@ -636,7 +636,7 @@ def _response_for(
636636

637637
response = self._do_request(uri, prepared_request)
638638
status = response.status_code
639-
content_type = response.headers["Content-Type"]
639+
content_type = response.headers.get("Content-Type")
640640
raw_body = response.text
641641
if status != 200:
642642
raise self._exception_for_error(status, content_type, raw_body, uri)

0 commit comments

Comments
 (0)