diff --git a/CHANGES b/CHANGES index 5df6cbe5..9732e665 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +0.25.8 +------ + +* Fix bug where the content type is always recorded as either text/plain or application/json. See #770 + 0.25.7 ------ diff --git a/responses/_recorder.py b/responses/_recorder.py index 151e47aa..b44fbc63 100644 --- a/responses/_recorder.py +++ b/responses/_recorder.py @@ -26,6 +26,7 @@ from responses import RequestsMock from responses import Response from responses import _real_send +from responses import _UNSET from responses.registries import OrderedRegistry @@ -153,6 +154,7 @@ def _on_request( status=requests_response.status_code, body=requests_response.text, headers=headers_values, + content_type=requests_response.headers.get("Content-Type", _UNSET), ) self._registry.add(responses_response) return requests_response diff --git a/responses/tests/test_recorder.py b/responses/tests/test_recorder.py index 9c27e2c2..fece12fc 100644 --- a/responses/tests/test_recorder.py +++ b/responses/tests/test_recorder.py @@ -58,7 +58,7 @@ def get_data(host, port): "url": f"http://{host}:{port}/202", "body": "OK", "status": 202, - "content_type": "text/plain", + "content_type": "image/tiff", "auto_calculate_content_length": False, } }, @@ -132,7 +132,7 @@ def prepare_server(self, httpserver): httpserver.expect_request("/202").respond_with_data( "OK", status=202, - content_type="text/plain", + content_type="image/tiff", ) httpserver.expect_request("/404").respond_with_data( "404 Not Found",